Forum Discussion

jantje1234's avatar
jantje1234
Visitor
4 years ago

Groovy: loop and run all teststeps using testcase properties

Hi all,

 

This is my first post on the smartbear community forum. I searched for a post something similar to my problem, but I couldn't find it. 

 

I am using SoapUI for many years now. We are building soap/xml integrations and use SoapUI for our Unit Tests. It started simple, but we are trying to make our project more and more reliable and stable using groovy scripts.

 

My test-projects often contains disabled DB-query and property transfer teststeps. These teststeps are only needed when the back-end gets a new clone and testdata needs to be refreshed. By disabling these (often very slow) query teststeps, our unit test projects run much faster.

 

I am trying to make a groovy script which can be executed to refresh the whole project in one run. This means that the groovy script needs to execute all teststeps, including the disabled teststeps. I already made the following script, which executes all teststeps in one testsuite (inlcuding the disabled ones). 

def testsuite = testRunner.testCase.testSuite
def currentTestCase = testRunner.testCase.name;

for(testcase in testsuite.testCaseList) {
    if (testcase.name != currentTestCase) {
        for (step in testcase.testStepList) {
             step.run(testRunner, context) 
        }
    }
}

 

However, some (disabled) teststeps use testcase properties (e.g. ${#TestCase#propertyName}  ). When running the teststeps using the script above, these properties are not resolved and the teststep failes.

 

Does anyone know how to make the testcase properties available to the teststeps? 

 

Thanks!

 

Jan

2 Replies

  • smtripathi99's avatar
    smtripathi99
    Occasional Contributor

    You can move the test case level properties to test suite or Project level and then access from there like ${#project#propertyName}

  • ZDGN's avatar
    ZDGN
    Contributor

    Hi jantje1234 

     

    You're right, such a command:

    context.expand('${#TestCase#Property}')

    won't give any result.

    Here is a workaround:

    testRunner.testCase.testSuite.project.testSuites["TestSuite"].testCases["TestCase"].getPropertyValue("Property")

    You will have to provide TestSuite and TestCase names, but it's easy to get them for sure.

     

    Hope this helps.

     

    David.