Forum Discussion

jomy10's avatar
jomy10
Occasional Contributor
7 months ago
Solved

Getting test steps in the correct order

I have a javascript which boils down to the following:

 

var testSteps = testRunner.testCase.testSteps.values().toArray();

for (var i = 0; i < testSteps.length; i++) {
    log.info(testSteps[i].getName());
}

 

When I run this, it will print out the test steps in the current test case. However, this does not print them out in the order they appear in the UI.

For Example, I have the following testCase:

 

When I run the script in this testCase, I get the following output:

Tue Aug 08 12:02:16 CEST 2023:INFO:> Groovy Script
Tue Aug 08 12:02:16 CEST 2023:INFO:> Another step
Tue Aug 08 12:02:16 CEST 2023:INFO:> GenerateReport

 

How can I get these testSteps in the correct order (so first GenerateReport, then Groovy Script and then Another step)

 

SoapUI version: 5.2.1

  • I figured it out, so for anyone who stumbles upon this post:

     

    replace 

    var testSteps = testRunner.testCase.testSteps.values().toArray();

    with

    var testSteps = testRunner.testCase.getTestStepList().toArray();

8 Replies

  • jomy10's avatar
    jomy10
    Occasional Contributor

    I figured it out, so for anyone who stumbles upon this post:

     

    replace 

    var testSteps = testRunner.testCase.testSteps.values().toArray();

    with

    var testSteps = testRunner.testCase.getTestStepList().toArray();
  • nmrao's avatar
    nmrao
    Champion Level 3

    It is mentioned "javascript". Are you sure? Where is that script present?

    • jomy10's avatar
      jomy10
      Occasional Contributor

      The script is located in the "GenerateReport" step (as seen in the screenshot).

    • jomy10's avatar
      jomy10
      Occasional Contributor

      nmrao I have Script Language set to Javascript in Project Properties. I can assure you that script runs javascript.

    • jomy10's avatar
      jomy10
      Occasional Contributor

      nmrao 

      It shows the following:

      Thu Aug 10 17:00:17 CEST 2023:INFO:[com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep@1721d7, com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep@aee2b8, com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep@1be5273]

       

      This also isn't in the right order, because when I add a REST step:

      The output becomes:

      Thu Aug 10 17:02:10 CEST 2023:INFO:[com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep@1a6b700, com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep@1721d7, com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep@aee2b8, com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep@1be5273]

      Where you can see the rest step is the first in the array, but it is the third in the test step.

  • nmrao's avatar
    nmrao
    Champion Level 3

    Ok.

    Not sure of your javascript selection.

    Groovy is more friendly, easy in my view.