Forum Discussion

ashkht's avatar
ashkht
Contributor
8 years ago
Solved

How to get TestStep Status as Passed/Failed using groovy

Hello,

 

I am trying out a way which can give me TestStep Status as Failed/Passed using groovy so that based on this status i can update Pass/fail against test case in excel from where it is data driven.

 

I have one assertion step for both positive and negative validations, which in turn consist multiple assertions, I wanted to get TestStep Status for corresponding assertion step, which will help me to decide what should be written in excel either Pass/Fail.

 

In one of community post, i got clue to use tear down script but i am not aware how it has to be run and how result from this tear down script can be implemented to decide status to be written as Pass/Fail in excel.


https://community.smartbear.com/t5/SoapUI-Pro/Get-all-test-step-result-of-a-test-case/td-p/27746

 

Solution Provided as : 

for( r in testRunner.results )
log.info "TestStep [" + r.testStep.name + "] finished with status " + r.status

 

Can you please assist me on the same.

Thanks,

Ashish 

  • You can get the status of individual assertions from the Assertion Test Step with the following script in the Groovy Test Step:

    def testStep = testRunner.testCase.getTestStepByName("Assertion") //change to your name
    def list = testStep.getAssertionEntryList()
     
    for( assertion in list)
    {
      //log.info(assertion.getProperties())
      log.info("Assertion: " + assertion)
      log.info("Assertion: " + assertion.status)
    }