Forum Discussion

emabindum's avatar
emabindum
Occasional Contributor
2 years ago

How to get the execution iteration number along with their respective assertion failed messages

Hi Team,

How to get the execution iteration number along with their respective assertion failed messages in testcase teardown script when we have Datasource(Excel) and Datasource loops steps to test the same functionality with multiple test data.

 

Below is the code which i am using in teardown script. with this i am able to get the total failed assertion messages, but the problem is not clear which iteration got failed and which got passed.(means if my test case run for 10 data rows based on the datasource loop step if one test case get failed i am geeting that failed messages but how can i know which iteration got failed among the 10)

 

My question is how to get the failed assertion messages test case iteration wise not steps wise from test case terdown script.

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

 

Thanks in advance

1 Reply

  • emabindum's avatar
    emabindum
    Occasional Contributor

    My question is how to get the failed assertion messages test case iteration wise not steps wise from test case terdown script.