Forum Discussion

anusha21's avatar
anusha21
Occasional Contributor
7 years ago

Status of Groovy Script test step by using groovy

HI All,

 

I have a Disabled test case which has many test steps (most of them are groovy test steps), 

 

I have written below code to get the status of test steps but it is not working for groovy test steps so some one please help me on this 

 

import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus

 

def TestCase = testRunner.getTestCase()
def StepList = TestCase.getTestStepList()
log.info StepList.size()
StepList.each{
if(it.metaClass.hasProperty(it,'assertionStatus')){
if(it.assertionStatus == AssertionStatus.FAILED){
log.info "${it.name} FAIL..."
}else if(it.assertionStatus == AssertionStatus.VALID){
log.info "${it.name} OK!"
}else if(it.assertionStatus == AssertionStatus.UNKNOWN){
log.info "${it.name} UNKNOWN (PROBABLY NOT ALREADY EXECUTED)"
}
}
}

 

this above code is only working for Request test steps but not for groovy scripts test steps , in my scenario i really need to get the status of test case but this test case is disabled so i thought i can get the status of test steps which solves the problem so please suggest me the solution

 

thanks

anusha

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I think this is supposed to be posted to the SoapUI community.

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      I am not sure you can just get the status of a groovy script. IE, I think the script has to run and then you can get the status. If you're checking this via groovy script you'd want something similar to:

       

      def result = context.testCase.testSteps["GC"].run(testRunner, context).getStatus().toString();
      
      if ( result == "OK")
      {
      	log.info("Test Script passed.")
      }
      else
      {
      	log.info("Test Script failed.");
      }