ContributionsMost RecentMost LikesSolutionsMake "Run Test Case" properties multi line When sending in data and returning data from a Run Test Case step, each property is single line. This is fine for simple values, but not particularly user-friendly for structured data like JSON. The properties could be multi line with the possibility of scrolling. Currently, I need to copy the data out and use a tool to reformat the data so it is readable. Current: A quick mock-up of what it might potentially look like : We use Run Test Case for things like putting a wrapper round an API call, (with error handling, retry, filtering, mapping functionality etc.) so if an API changes we only need to change it in one place rather than in each test case. We pass the whole JSON payload in and the whole JSON Response back. (If for some reason it would break existing functionality then have an "enable multi-line" checkbox) ALTERNATIVLY: If not possible, then a button at the end of the table row to open the value in a new window (similar to a the Groovy Script run result-output): Re: Groovy - Get the name of the test case that called the "Run Test Case" for this test case That's fantastic! Thanks Rao! Re: Groovy - Get the name of the test case that called the "Run Test Case" for this test case Hopefully this image makes it clearer Rao. I'm looking for a command or way that would work like my made-up "getTheTestCaseThatCalledMe()" function. The reason I'd rather not pass the value through is, there are well over a hundred calls to different CommonTest1 type test cases. It is of course do-able but it'd be cleaner, safer quicker and easier if we didn't need to. The code shown in the image for "WhoCalledMe" Groovy script step: log.info testRunner.getTestCase().getName().toString() /* equals "CommonTest1" */ log.info context.expand( '${#TestCase#input_passedInPropertyTestCaseName}' ) /* Equals the "ABC123" that I want, but requires that property value to be passed in */ //log.info testRunner.getTestCase().getTheTestCaseThatCalledMe().getName().toString() /* getTheTestCaseThatCalledMe() of course does not exist */ Re: ReadyAPI Smart Assertion Not as far as I know in the ReadyAPI software 😞. Ideally you'd want to import (dynamically) too! Its a massive flaw of Smart Assert imho. We've created our own Groovy script that uses a JSON file that acts as a map, to assert the properties of the test data and the returned data. For a more manual method, in a composite project you could look at the source files 🤤 e.g. <?xml version="1.0" encoding="UTF-8"?> <con:testCase xmlns:con="http://eviware.com/soapui/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="cba17ad8-eaa2-4780-b626-32a9924b564d" discardOkResults="false" failOnError="false" failTestCaseOnErrors="true" keepSession="false" name="Test Case 1" searchProperties="true" timeout="0"> <con:settings id="b770fa28-5ff4-4b15-b725-af70cc98a55c"> <con:setting id="cba17ad8-eaa2-4780-b626-32a9924b564dfileName">Test-Case-1</con:setting> </con:settings> <con:testStep type="groovy" name="Groovy Script" id="d4dcd68e-a392-49de-9d6c-a6576304e488"> <con:settings/> <con:config> <script>""" { "abc":"def", "ghi":"jkl" } """</script> </con:config> </con:testStep> <con:testStep type="assertionteststep" name="Assertion" id="5d473562-aba5-4574-819f-e9ddf2c622d8"> <con:settings/> <con:config xsi:type="con:AssertionTestStep"> <con:entry> <con:id>87c63781-b2f0-45cf-b9e0-c42a9f974732</con:id> <con:isGroup>false</con:isGroup> <con:sourceId>d4dcd68e-a392-49de-9d6c-a6576304e488</con:sourceId> <con:propertyName>result</con:propertyName> <con:assertion type="DataAndMetadataAssertion" name="Smart Assertion" id="8e970b5a-5798-4eec-a116-9927810845df"> <con:configuration xsi:type="con:DataAndMetadataAssertion"> <con:mode>Received Data</con:mode> <con:elements> <con:path>$['abc']</con:path> <con:element>abc</con:element> <con:operatorId>1</con:operatorId> <con:enabled>true</con:enabled> <con:expectedValue>def</con:expectedValue> <con:caseSensitive>true</con:caseSensitive> <con:numberType>false</con:numberType> <con:expectedDataType>1</con:expectedDataType> </con:elements> <con:elements> <con:path>$['ghi']</con:path> <con:element>ghi</con:element> <con:operatorId>1</con:operatorId> <con:enabled>true</con:enabled> <con:expectedValue>jkl</con:expectedValue> <con:caseSensitive>true</con:caseSensitive> <con:numberType>false</con:numberType> <con:expectedDataType>1</con:expectedDataType> </con:elements> <con:originalMessage>{ "abc":"def", "ghi":"jkl" }</con:originalMessage> </con:configuration> </con:assertion> </con:entry> </con:config> </con:testStep> <con:properties/> <con:reportParameters/> </con:testCase> Groovy - Get the name of the test case that called the "Run Test Case" for this test case Get the name of the test case that called the "Run Test Case" for this test case in Groovy: Test Suite: "ABC" has Test case "ABC123", which has a "Run Test Case" step, that runs "CommonTest1" test case (in Test Suite "Common"). I want the Groovy script in CommonTest1 to log/use the name of the Test case that called it. That is: "ABC123". Ideally without passing in "context.currentStep.name" as a parameter. Help much appreciated. Solved"Update Definition" blanks out parameters in associated test cases I doing something wrong? Is my API definition wrong (its exported from Azure API Manager)? I click on Update Definition for my API, I look at my test cases and they've all lost their values. As though "Revert all parameters to default values" button has been pressed on all of them. Is this a feature?! I'll need to put those parameters in again, for each of the dozens of test cases each time the API definition changes, which seems wrong. I tried adding 'default' values to the Open API YAML as a rough work around but they don't seem to get picked up anyway. Using ReadyApi ver 3.44. Regards, John SolvedRe: Make Smart Assertion more useful with added features Heartily agree! Smart Assertions are cool and I want to like them but not advanced enough and need improving. Maybe if there was an export and import would make it easier to edit the valid values (e.g. find and replace Property Expansions)? Here are some the Groovy script work arounds we use, if of any use? //Assert Date comparison expectedDateString = "2023-01-16T18:43:34.3210487" returnedDateString = "16/01/2023" expectedDate = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS", expectedDateString) returnedDate = new Date().parse("dd/MM/yyyy", returnedDateString) assert expectedDate > returnedDate assert expectedDate < returnedDate.plus(365) //Assert Mapping comparison expectedMapValue = "Hazel" returnedMapValue = "Ha" def genderMap = [ Hazel:'Ha', Brown:'Br', Blue:'Bl', Green:'Gr' ] assert genderMap.get(expectedMapValue) == returnedMapValue //Assert RegEx comparison expectedRegExValue = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+[.][a-zA-Z]{2,}\$" returnedRegExValue = "no-reply@abc.co.uk" assert returnedRegExValue =~ expectedRegExValue //Assert conditional comparison expectedValue = "123" dependantValue = true if (dependantValue == true) { assert expectedValue == "123" } else { assert expectedValue == "ABC" } //Assert Contains expectedListValues = ["animal", "vegetable", "mineral"] returnedListValue = "animal" assert expectedListValues.contains(returnedListValue) //Out of order simple array expectedArray = ['FET','SOL'] returnedArray = ['SOL','FET'] returnedArraySorted = returnedArray.sort() assert expectedArray == returnedArraySorted //Out of order object array import groovy.json.* returnedObjArrayString = """ { "user_identifier" : [ { "value" : "10000571", "id_type" : { "value" : "BARCODE", } }, { "value" : "atzejr-dnkuifa", "id_type" : { "value" : "OTHER_ID_1", } } ] }""" returnedObjArray = new JsonSlurper().setType(JsonParserType.LAX).parseText(returnedObjArrayString) //directAccessAValue = returnedObjArray.user_identifier[0].value for (row in returnedObjArray.user_identifier) { if (row.id_type.value == "BARCODE") { assert row.value == "10000571" } if (row.id_type.value == "OTHER_ID_1") { assert row.value == "atzejr-dnkuifa" } } We also have a Groovy script that's a for-loop in a for-loop, for when we can auto match the sent JSON to the returned JSON and assert the values. Re: Groovy JSON value types Found this documentation The Apache Groovy programming language - Parsing and producing JSON (groovy-lang.org) Groovy JSON value types I'm using Groovy to loop through a JSON document returned by an API and will need to act / respond differently depending on the JSON value type. e.g. is the value an array or an object. The code below uses regex and works ok, but I'm sure there's a better way. (Looking at Groovy list methods but nothing obvious to me Groovy - Lists (tutorialspoint.com)) import groovy.json.* def myJsonString = """ { "a": "value1", "b": { "b1": "object value1", "b2": "object value2" }, "c": [ {"c1": "object array value1"}, {"c2": "object array value2"} ], "d": ["array value1", "array value2"], "e": null, "f": 1, "g": true } """ def myJson = new JsonSlurper().setType(JsonParserType.LAX).parseText(myJsonString) def myJsonKeys = myJson.collect{"${it.key}"} for(item in myJsonKeys) { log.info "=== KEY: " + item.toString() + " ===" def keyValue = myJson.get(item.toString()).toString() log.info keyValue if(keyValue =~ '^\\{.*\\}$') { log.info "This is an object" } else if (keyValue =~ '^\\[\\[.*\\]\\]$') { log.info "This is a object array" } else if (keyValue =~ '^\\[.*\\]$') { log.info "This is an array" } else { log.info "This is a key value pair" } } the output is INFO: === KEY: a === INFO: value1 INFO: This is a key value pair INFO: === KEY: b === INFO: {b2=object value2, b1=object value1} INFO: This is an object INFO: === KEY: c === INFO: [[c1:object array value1], [c2:object array value2]] INFO: This is a object array INFO: === KEY: d === INFO: [array value1, array value2] INFO: This is an array INFO: === KEY: e === INFO: null INFO: This is a key value pair INFO: === KEY: f === INFO: 1 INFO: This is a key value pair INFO: === KEY: g === INFO: true INFO: This is a key value pair (boolean / null / integers don't really concern me for this, mainly if its an array object or object.) Any pointers appreciated. Thanks. Solved