Forum Discussion

emabindum's avatar
emabindum
Occasional Contributor
2 years ago
Solved

tear down script to get each iteration failed assertion messages at testcase level

Hi Team,

In my test cases i have Datasource(Excel) and Datasource loops steps to test the same functionality with multiple test data.

 

Below is the teardown script am using at test case level. But with this i am getting the last executed test data related failed assertion messages only(means if my test case run for 10 data rows based on the datasource loop step i am getting 10th iteration execution details only.)

 

How to get  failed assertion messages for all the iterations of a test case.

 

def step_a = "";
for (testStepResult in testRunner.getResults() )
{
def testStep = testStepResult.getTestStep()
step_a = step_a + "TestStep [ " + testStep.name + " ] finished with status " + testStepResult.getStatus().toString() + "\n"
//log.info testStep.testRequest.response.responseHeaders
if (testStep instanceof com.eviware.soapui.model.testsuite.Assertable)
{
for( assertion in testStep.assertionList )
{
def messages = ""
def isAssertionLogged = false
for( message in testStepResult.getMessages() )
{
if(message.contains(assertion.name))
{

messages = messages + testStep.name + "- Error [" + message + "]" + "\n";;
isAssertionLogged = true
break
}
}

if(isAssertionLogged) //if there is no error message for the assertion, the assertion is either passed (VALID) or was not ran (UNKNOWN)
{
step_a = step_a + "Assertion [" + assertion.label + "] has status [FAILED]" + "\n";
step_a = step_a + messages;
}
else {
if(assertion.isDisabled()) {
step_a = step_a + "Assertion [" + assertion.label + "] has status [UNKNOWN]" + "\n"
}
else {
step_a = step_a + "Assertion [" + assertion.label + "] has status [OK]" + "\n"
}
}
}
}
log.info( step_a)
}//end for


log.info "Let’s get Test run results"
File file = new File("C:/Users/cn326923Results/TestRunnerStatus20.txt")

file.write step_a

 

 

  • emabindum,

    you have multiple options:

    • You can add a Groovy script test step into the loop and do everything in that Groovy script.
    • You can increase the "Max Results" configuration in Test Case settings, and then the test step results of the past iterations will also be available.
    • Use a TestRunListener afterStep method to handle the tear-down activities.

     

2 Replies