Forum Discussion

gouseferoz's avatar
gouseferoz
New Contributor
8 years ago
Solved

logs are not getting generated correctly when use teardown script

I am using teardown script to log the status of each step of my project.

 

My Project outline:

Step 1: Datasource

Step 2 : HTTP step with Message content assertion

Step 3 : Datasource loop

 

My datasource has 3 lines of data so the loop will execute for three times. For the first two times the Step2 passes and for the third time the Step2 fails which is intended. 

But the log file i generated using the Teardown script is showing the Step2 as pass for the first two cases but the Message content assertion is showing errors which is the error that got for the third loop.

 

Teardown script:

 

log.info "Lets get Test run results"
def step_a = "";

step_a = "Test Case [" +testRunner.testCase.name+ "]\n"
for( r in testRunner.results )
{
       if ( r.testStep instanceof com.eviware.soapui.model.testsuite.Assertable)
      {
            step_a = step_a + " TestStep [ " + r.testStep.name + " ] finished with status " + r.status + "\n" ;
            if(!r.status.contains("OK"))
            {
                  for( assertion in r.testStep.assertionList )
                  {
                        step_a = step_a + "Assertion [" + assertion.label + "] has status [" + assertion.status + "]" + "\n";
                        for( e in assertion.errors )
                             step_a = step_a + "- Error [" + e.message + "]" + "\n";
                  }
             }  
        }
        else // Non-Assertable steps
       {
               step_a = step_a + " TestStep [ " + r.testStep.name + " ] finished with status " + r.status + "\n" ;
               // log.info step_a
        }
}
def groupID = context.expand( '${#Project#GroupID}' )
log.info groupID
def groupID1 = context.expand( '${#Global#GroupID}' )
log.info groupID1

File file = new File("C://SoapUI//Results//TestRunnerStatus.txt")
if( file.exists() ) {
file.append step_a
}
else{
file.write step_a
}

 

The Log file is something like this:

  1. Step 1 passed with status OK
  2. Step 2 passed with status OK
  3. Assertion Failed with message
  4. Step 3 passed with status OK
  5. Step 1 passed with status OK
  6. Step 2 passed with status FAILED
  7. Assertion Failed with message
  8. Step 3 passed with status OK
  9. Step 1 passed with status OK
  10. Step 2 passed with status FAILED
  11. Assertion Failed with message
  12. Step 3 passed with status OK

 

Please help me whats going wrong