Forum Discussion

kgbheem's avatar
kgbheem
Occasional Contributor
7 years ago

how do i get the assertions list test data wise in a test

i have scenario where i used datasoure to  validate for multiple test data, here i want to get the assertions test datawise like  testdata1               1. assertion passed( need to print actual v...
  • Radford's avatar
    7 years ago

    While not exactly what you requested, the following code can be placed into a TestRunListener.afterRun event handler it shows you how to get hold of the assertion error message that Ready API displays:

     

    import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus
    
    def logPrefix = testRunner.getTestCase().getName() + ': '
    
    // Loop through all of the test step results.
    testRunner.getResults().each(){ testStepResult ->
    
    	log.info(logPrefix + 'Test step ' + testStepResult.getTestStep().getName() + ' result status = ' + testStepResult.getStatus().toString())
    
         // Loop through all of the assertions.
         testStepResult.getTestStep().getAssertionList().each() { assertion ->
    
    		log.info(logPrefix + 'Assertion ' +  assertion.getName() +  ' returned status = ' + assertion.getStatus())
    
    		// Check to see if current assertion has failed?
    	     if(assertion.getStatus().toString().equals('FAILED')){
    
    			// Loop through all of the failed assertions error messages
    			assertion.getErrors().each() { assertionError ->
    	      		log.info(logPrefix + assertionError.getErrorLevel().toString() + ' message = ' + assertionError.getMessage())
    	      	}
    	     }
         }
    }

     

    Hopefully this will get you started.