Forum Discussion

HanTest's avatar
HanTest
Occasional Contributor
9 years ago
Solved

Get the status of a teststep that already has been executed

I want to get the status of a previously runned teststep in a groovyscript step.

How can this be done?

  • nmrao's avatar
    nmrao
    9 years ago

    The step2 actually running the step1 as well to get the status.

     

    When go thru the question again, looks you are interested only getting the status not actually running it. 

    So, another example for the same, but this wont run the previous step again.

     

    import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep
    import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepResult
    def step = context.testCase.testStepList[context.currentStepIndex - 1]
    assert step instanceof WsdlTestStep
    def result = new WsdlTestStepResult(step)
    log.info result.status

10 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Took two steps to try this.

     

    1. step1 - groovy script - this dynamically passes at times and fails at times

    2. step2 - groovy script - which is actully you are interested in to find the status of step2 in here.

     

    I know you may not be interested in step1, just giving  for the testablity for someone.

     

    Script that is part of step1

    /**

    * generate a randon number, fail the step if non-zero

    **/

    def result = ((new Random().nextInt(2))+1)%2
    assert result, "failed the test"

    ---------------------------------------------------------------------------------------

     

    Script that is part of step2 

    /**

    * get the previous test step index, then get the previous test step name

    * run the test step by its name

    * get its status

    **/

    def step1Result = testRunner.runTestStepByName(context.testCase.testStepList[context.currentStepIndex - 1].name)
    log.info step1Result.status

    • nmrao's avatar
      nmrao
      Champion Level 3

      The step2 actually running the step1 as well to get the status.

       

      When go thru the question again, looks you are interested only getting the status not actually running it. 

      So, another example for the same, but this wont run the previous step again.

       

      import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep
      import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepResult
      def step = context.testCase.testStepList[context.currentStepIndex - 1]
      assert step instanceof WsdlTestStep
      def result = new WsdlTestStepResult(step)
      log.info result.status

      • HanTest's avatar
        HanTest
        Occasional Contributor

        This is exactly what I was looking for thank you very much!