Forum Discussion

JanPot's avatar
JanPot
Occasional Contributor
9 years ago

Name of the last test step ran

Hi,

 

I would like if there is a way for a groovy script to 'know' the name of the last Test Step that was run... Not the previous step in the list of step, but really which step was last run.

 

Thanks

  • Hmm.. Instead of groovy script test step, you can just have that as Script Assertion for the same last test step that you run.
  • nmrao's avatar
    nmrao
    Champion Level 3

    Can you elaborate your use case? Do you mean any disabled steps in between?

    By the way, where do you want that, in a teardown of test case?

    • JanPot's avatar
      JanPot
      Occasional Contributor

       

      The thing is that I have a groovy script that I need to run after many test case steps, the script is always the same, it takes a value from the answer of the REST calls made by the Test Steps... 

      The script looks like this so far, since I copied the script after each step:

       

      def ResponseValue2 = context.testCase.testStepList[context.currentStepIndex - 1].httpRequest.response.responseHeaders["Location"][0]

       

      if (ResponseValue2.length() >= 107) {

        do something with this value

      }

       

      I thought that if instead of using context.testCase.testStepList[context.currentStepIndex - 1] I could use something that would give me the latest step run, I could just call the script once.

       

      Basically that's it... hopefully things are a little bit clearer :-)

      • nmrao's avatar
        nmrao
        Champion Level 3
        Hmm.. Instead of groovy script test step, you can just have that as Script Assertion for the same last test step that you run.