Forum Discussion

ripplegupta's avatar
ripplegupta
Contributor
8 years ago

How to get result of all test steps in groovy test step of last test suite.

Please help here... Thanks in advance.

 

I have three test suites in one project. Last one contains only one test case which contains a groovy test step. How can I get status(i.e.failed/ok) of all test steps from all test suites in groovy test step of last suite?

 

Following data I need in groovy test step :

  1. Result (pass or failed) of each test step in all test suites. (i can traverse through assertion list in case of jdbc or rest request but other steps like data source, groovy script dont have assertions, i can only check their status to know whether its pass or failed.
  2. Error message if test step is failed.

 

I tried below code in groovy test step but UNKNOWN is returned.

getTestStepList().each
{
assert it instanceof WsdlTestStep
			      def result = new WsdlTestStepResult(it) 
			      log.info result.status
}

 

2 Replies

  • Radford's avatar
    Radford
    Super Contributor

    While this is not eaxctly what you asked, here is a project teardown script that iterates through all of its test suites, cases, and steps to get the results, this may point you in the right direction.

     

    log.info('Project ' + runner.getProject().getName() + ' TestRunner.Status = ' + runner.getStatus())
    
    runner.getResults().each{ testSuiteRunner ->
    
    	log.info('Test Suite ' + testSuiteRunner.getTestSuite().getName() + ' TestRunner.Status = ' + testSuiteRunner.getStatus())
    	
    	testSuiteRunner.getResults().each{ testCaseRunner ->
    	
    		log.info('Test Case ' + testCaseRunner.getTestCase().getName() + ' TestRunner.Status = ' + testCaseRunner.getStatus())
    
    		testCaseRunner.getResults().each{ testStepResult -> 
    			log.info('Test Step ' + testStepResult.getTestStep().getName() + ' TestStepResult.TestStepStatus = ' + testStepResult.getStatus())
    		}
    	}
    }

     

    Take a look at the TestRunner interface and it various subinterfaces for more information.

     

    The following post:

     

    https://community.smartbear.com/t5/SoapUI-NG/how-can-I-invalidate-a-test-if-the-data-is-not-found-on-a/m-p/128027#M29521


    Details how to deal with test steps that do not have assertions (eg groovy test step)

     

    As for messages, the TestStepResult has a getMessages() method that returns an array of strings, you could add in something to the processing of the test step results above like:

     

    // Assumes you've already defined the variable testStepResult
    if(testStepResult.getStatus().toString() != 'OK' ){ testStepResult.getMessages().each{ message -> log.error('message = ' + message) } }
    • ripplegupta's avatar
      ripplegupta
      Contributor

      Thanks for answering Radford.

       

      That gives me hint and groovy test step returns empty on runner.status for each previous test step.

       

      So i made 1 event handler that will access test step results and do further actions ..