Forum Discussion

Nikolaj's avatar
Nikolaj
Occasional Contributor
13 years ago

How to launch LoadTest as one of the step in TestCase

Hi All,

I have a simple question.I need to launch LoadTest as one of the steps in TestCase on SoapUI 4.5.
The situation is like this:

TestSuite
TestCase1
Step11
Step12
TestCase2
Step21
Step22
LoadTest1
TestCase3
Step31
Step32

When I start TestSuite, all TestCase succeesfully running, but LoadTest1 not started.
When I start TestCase2, all TestSteps succeesfully running and completed, but LoadTest1 not started.

Manually I can launch LoadTestRunner, but I want that LoadTest automatically to start when TestCase2 running or when TestCase2 completed.

Please tell me how I do it better.

Any suggestion is appreciated.

Thanks in advance.
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    You can put something like this in a Groovy script step (or Setup or Teardown scripts) where you want it to start:


    def loadTest = testRunner.testCase.testSuite.getTestCaseByName('MyTestCase').getLoadTestByName('MyLoadTest')
    loadTest.run()

    and use this when you want to stop it:

    def loadTest = testRunner.testCase.testSuite.getTestCaseByName('MyTestCase').getLoadTestByName('MyLoadTest')
    if (loadTest.isRunning()) {
    loadTest.getRunner().cancel('Test done')
    }
  • Nikolaj's avatar
    Nikolaj
    Occasional Contributor
    Thanks for the answer!

    When I start Groovy script as a TestCase step:

    def loadTest = testRunner.testCase.testSuite.getTestCaseByName('TestCase1').getLoadTestByName('LoadTest1')
    loadTest.run()


    Error occurs: java.lang.NullPointerException: Cannot invoke method getLoadTestByName() on null object

    What am I doing wrong ?

    An as example attached soapui project
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Watch your spaces. The names in the project are 'TestCase 1' and 'LoadTest 1' but you are using 'TestCase1' and 'LoadTest1' in the script.