Forum Discussion

Manimaran's avatar
Manimaran
Occasional Contributor
12 years ago

How to know which teststep is running?

Hi,
I have set of test steps(Test Request Steps) inside a test case as below and one groovy step. Based on my input from excel, i run a particular request step and at the same time, i will disable all other request steps on the same run. In groovy step, i do some validation based on the executed test step (request step). How can i get the test step name of the executed test step on each time or for each run from the Groovy step? Can anyone help me.

Test Case1
Test Request 1
Test Request 2
Test Request 3
Groovy Step

7 Replies

  • Try the following:
    def stepName = context.getCurrentStep().getLabel()


    Thanks,
    Michael Giller
    SmartBear Software
  • Manimaran's avatar
    Manimaran
    Occasional Contributor
    It just gives the step name as 'Groovy Step'. But what i need is, for one of my test case, i will be running 'Test Request 2' and at the same time my other two test requests will be disabled. So at this point of time, Test Request 1 and 3 will be in disabled mode, Test Request 2 will be in enabled mode and it was the one executed. Now once after executing the request, it comes to groovy step and here i need to get the name of the executed test request (i.e; immediate previous executed test step name. for eg, I should get the name as 'Test Request 2'). how should i get that? Please help me.
  • I suggest that you add a custom property to the test suite. When you disable the other steps, save the label of the test step to execute in the property and then retrieve it in the Groovy step.

    Best regards,
    Manne
    SmartBear
  • Manimaran's avatar
    Manimaran
    Occasional Contributor
    I got you. but in some cases, i will have series of steps to be executed and series of steps to be disabled. please find below example. i have a test case like below.

    TestCase1
    ---1-Groovy Script
    ---1-TestRequest
    ---1-ConditionalGoTo
    ---1-PropertyTransfer
    ---2-Groovy Script
    ---2-TestRequest
    ---2-ConditionalGoTo
    ---2-PropertyTransfer
    ---Groovy Validation Step

    here, as i said before, for some test case, i will be disabling the series of steps i.e; from above, steps starts with '1- ...' and will run the steps starts with '2- ...'. so at this point of time, i have to know which TestRequest is run at this time, so that i can do validation based on that in the Groovy Validation Step. For this, from this case, more test steps are run ( '1- ...'), but i need to specifically get the name of the XML request step (here '1-TestRequest').

    The reason behind is, i have lots of test steps inside my test case (based on my requirement). so i have to do in the above manner and i am looking this solution to get the executed test request name. Could you please help me, is there any ways that i can get from Groovy code?
  • Manimaran's avatar
    Manimaran
    Occasional Contributor
    Basically, i want to identify and get the XML test request step name from the series of steps in that test cases. I can store the step as you said, but still i have to store more than 5 step names for a single run (as this is my configuration, based on my requirement) and this will again confuse me to get the name of XML request name (as if we hard coded). So i am looking for, is there any way that i can get the previously executed XML test request name using Groovy? (there could be lots of request executed for single run, but have to identify the XML test request step name). Please help me.
  • I would suggest a different approach. Instead of executing a Groovy script step and trying to figure out what ran beforehand, I would add the code in an event script (http://www.soapui.org/Scripting-Propert ... dlers.html) and then log a step name for each step that ran.

    Or I would use a Script Assertion in each step where I would log/append the step name and just return "assert true"

    Thanks,
    Michael Giller
    SmartBear Software