Forum Discussion

zorglups's avatar
zorglups
Occasional Contributor
5 years ago

Get current TestStep.operation from a DataGen property of type script.

In a Test Step, my SOAP request contains <context>${DataGen#context}</context>

 

DataGen is ... a DataGen TestStep that defines a property 'context' of type Script (READ).

 

In the script, I tried:

def tstep = testRunner.runContext.currentStep.name;

return tstep


def currentTestStep = context.getCurrentStep().getLabel()

return currentTestStep 

 

But then ${DataGen#context} evaluates to 'DataGen' while I would like it to evaluate to the current TestStep name.

 

Well... Ultimately, I would like to have the current TestStep operation.name and based on this apply some logic to define the context. So the DataGen script is needed.
I just fail to get properties of the TestStep properties from which the DataGen properties is "evaluated".

 

Any help is welcome.

7 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    Have you tried this snippet? This is what I have used in the past to get the current test step name. 

     

     

    def teststepName = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()
    
    return teststepName;
    

     

     

     

    • zorglups's avatar
      zorglups
      Occasional Contributor

      Hello msiadak,

       

      Thank you so much for your fast reply.

       

      My DataGen testStep name is "MyDataGen".

       

      My SOAP operation testStep name is "checkAccessControl".

      It contains: <context>${MyDataGen#context}</context>

       

      The 'context' property of the MyDataGen DataGen TestStep is of type Script/READ and contains this:

      def teststepName = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()

      return teststepName;

       

      Upon execution of the checkAccessControl testStep, the variable evaluates to MyDataGen as seen in the Raw tab:

      <context>MyDataGen</context>

       

      I was in a hurry to come to the office this morning to test your suggestion :-(

      Unfortunatelly, this does not address my issue.

      • groovyguy's avatar
        groovyguy
        Champion Level 1

        zorglups: Can you show me a screenshot of what your tests look like? What SHOULD be shown in the <context></context> element?