Forum Discussion

jzyling's avatar
jzyling
Occasional Contributor
13 years ago

Varying parameter in load test

Hi,

I created a REST HTTP Request for a POST Method, using JSON data in the body. I am trying to do the load test by sending POST requests to multiple locations with different deviceId in order to check the total consuming time.

The path used for POST is "..../device/{device_ID}"

POST Body:
{
"accountId":2500000000,
"deviceId":${device_ID},
"key":"Program",
"value":"on"
}

For example, device_ID is set from 1001 to 2000. May I ask how to do this load test by using SOAPUI? I couldn't find the way to set varied deviceId.

Thanks a lot in advance!

1 Reply

  • Just an idea, create a groovy script teststep which will set and fire the request.
    Create your loadtest under the same testcase, which will run the script.
    The request is in another testcase, which has a custom property (here named ID).

    This is very simple, since it runs from id = 1000 to 2000 step by step

    See the attached screenshot.png

    The script could look like this

    def req = testRunner.testCase.testSuite.project.testSuites['testsuite'].testCases['testcase1']
    def device_ID = req.getPropertyValue('ID')
    def request =
    """
    <post>
    <accountId>2500000000</accountId>
    <deviceId>${device_ID}</deviceId>
    <key>Program</key>
    <value>on</value>
    </post>
    """

    req.setPropertyValue('ID', (device_ID.toInteger() + 1).toString())
    req.testSteps['request'].getProperty('Request').setValue(request)

    req.run(null, false)

    //save the requests and responses
    def writer = new File('d:/log.txt')
    writer.append('\nrequest\n')
    writer.append(req.testSteps['request'].getProperty('Request').getValue())
    writer.append('\nresponse\n')
    writer.append(req.testSteps['request'].getProperty('Response').getValue())