Forum Discussion

arunbharath's avatar
arunbharath
Contributor
5 years ago
Solved

How to get a test-step response from Suite TearDown script?

Hi All. I trying to get step step response of each test case from suite TearDown script. def testCaseCount = runner.testSuite.getTestCaseCount() for (int i=0;i<testCaseCount;i++){ def testCaseName...
  • nmrao's avatar
    5 years ago

    arunbharath 

    Here you go:

     

    Please follow comments inline

    /**
    * Tear down script of suite
    **/
    
    import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep
    def processStep = { 
    	log.info "Step name : ${it.name}"
    	log.info "Case name : ${it.testCase.name}"
    	log.info "Suite name : ${testSuite.name}"
    	log.info "Response :\n ${it.testRequest.responseContentAsString}"
    	//Write logic below to save the response data to file here
    }
    
    testSuite.testCaseList.collect { kase ->
    	kase.testStepList.collect {
    		switch(it) {
    			//Process only REST requests; add additional cases as needed
    			case {it instanceof RestTestRequestStep}:
    				processStep it
    				break
    			default:
    				break
    		}
    	}
    }

    If you don't want to have the above script for each test suite or project, then you can use events, "TestRunListener.afterStepand have relevant logic to do the same.