Reputation: 65
If you run a testStep and look at the Assertions. SoapUI returns the assertion Green/Red as well as adding "- VALID" or "- FAILED"
Question: Is there a way to captuer that full string? The name + status
i.e. SOAP Response - VALID XPath Match - VALID Contains - VALID Not Contains - FAILED
Currently I'm pulling the assertionsList - but I want the extra status piece to go along with it.
Thank you, Rob
Upvotes: 1
Views: 4818
Reputation: 18507
To print all assertions from all the testSteps
inside a testCase
you can use the follow groovy script in a tearDown script
of your testCase
, it use the getAssertionList()
which returns a TestAssertion
list, and then iterates over it using label
and status
property:
testRunner.testCase.testSteps.each{ name,props ->
log.info "Test step name: $name"
// check that the testStep class support assertions
// (for example groovy testStep doesn't)
if(props.metaClass.respondsTo(props, "getAssertionList")){
// get assertionList
props.getAssertionList().each{
log.info "$it.label - $it.status"
}
}
}
Note: Not all kind of testStep's have assertions (e.g Groovy script testStep doesn't) so it's necessary to check it before use getAssertionList()
)
If you want to get all assertions from one specific testStep
you can use the same approach in a groovy script:
// get the testStep
def testStep = testRunner.testCase.getTestStepByName('Test Request')
// check that the testStep specific class support assertions
// (for example groovy testStep doesn't)
if(testStep.metaClass.respondsTo(testStep, "getAssertionList")){
// print assertion names an its status
testStep.getAssertionList().each{
log.info "$it.label - $it.status"
}
}
Hope it helps,
Upvotes: 1