Forum Discussion

nouvelle's avatar
nouvelle
Occasional Contributor
13 years ago

Soap requests containing incremental values

Hi,
I'm a beginner SOAP UI user.
Performing the load tests I should send soap requests in such way: request by request a value should increase. E.g.: arg=arg1 the first request, arg=arg2 the second one and so on….
I would be very grateful to anyone who will support me.

7 Replies

  • Hi,

    This can be achieved by Groovy script.

    Are you trying to say only one request that will be executed n number of times or they are multiple requests and just value needs to be increased?

    Regards,
    Rohit Shingalapur
  • nouvelle's avatar
    nouvelle
    Occasional Contributor
    Hi Rorit,
    Many thanks for your help.
    I have one request that will be executed n number of times, each time the parameter, which I called arg before, assumes values like arg1, arg2 and so on.

    BR
  • Hi.

    Ok, Then follow the following steps:

    Step 1: Create a soapUI project and test suite and a test case within the test suite.

    Step 2: Create a property at test case level say "incrementValue" and assign some value say 1

    Step 3: Now add your Request say "Request 1" in this request add ${#TestCase#incrementValue} to the input element in the request.
    So that it will take the value from the property that you have created at test case level i.e. incrementValue

    Step 4: Now add Groovy step after the step "Request 1". Then add the following code in that

    def incrementValue = context.expand( '${#TestCase#IncrementValue}' );
    incrementValue = incrementValue.toInteger() + 1;

    if (incrementValue <= 10) {
    testRunner.testCase.setPropertyValue("IncrementValue", incrementValue);
    log.info "IncrementValue: "+incrementValue;
    testRunner.gotoStepByName("Request 1");
    }

    Step 5: Double click on the test case level and Test case editor will be displayed click on green button.

    That's it!!!!!!!

    Your request will be executed 10 times as per the groovy. Please remember to mention this otherwise it will run infinite times causing memory outage.

    Hope this helps!!

    Regards,
    Rohit Shingalapur
    http://rohit-developerscorner.blogspot.com/
  • nouvelle's avatar
    nouvelle
    Occasional Contributor
    Hi Rohit,
    Really many thanks !!!
    I got your nice help and now I can proceed :-D

    Best regards
  • dmltn84's avatar
    dmltn84
    Occasional Contributor
    Hello,

    I am using this code for groovy script based on your instructions

    def incrementValue = context.expand( '${Properties#incrementValue}' );
    incrementValue = incrementValue.toInteger() + 1;

    if (incrementValue <= 10) {
    testRunner.testCase.setPropertyValue("IncrementValue", incrementValue);
    log.info "IncrementValue: " + incrementValue;
    testRunner.gotoStepByName("xxx");
    }


    xxx - is a test step with request containing value which should be incremented

    Output is as follows:


    groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [incrementValue, 2] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [incrementValue, 2] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String)


    I expanded script to look as follows, but it runs only once:

    def incrementValue = context.expand( '${Properties#incrementValue}' );
    incrementValue = incrementValue.toInteger() + 1;
    incrementValue = incrementValue.toString();

    if (incrementValue <= 10) {
    testRunner.testCase.setPropertyValue("incrementValue", incrementValue);
    log.info "incrementValue: " + incrementValue;
    testRunner.gotoStepByName("xxx");
    }


    Test steps are arranged in the following order:
    1. Properties(1)
    2. xxx
    3. groovy script

    Can you please advise what should be corrected?
  • dmltn84 wrote:

    I expanded script to look as follows, but it runs only once:

    def incrementValue = context.expand( '${Properties#incrementValue}' );
    incrementValue = incrementValue.toInteger() + 1;
    incrementValue = incrementValue.toString();

    if (incrementValue <= 10) {
    testRunner.testCase.setPropertyValue("incrementValue", incrementValue);
    log.info "incrementValue: " + incrementValue;
    testRunner.gotoStepByName("xxx");
    }


    Test steps are arranged in the following order:
    1. Properties(1)
    2. xxx
    3. groovy script

    Can you please advise what should be corrected?


    It is running only once because your are setting the property value at the TestCase level and for condition check, you are accessing this from the test step i.e. Properties. So try the below

    testRunner.testCase.getTestStepByName("Properties").setPropertyValue("incrementValue", incrementValue);

    instead of testRunner.testCase.setPropertyValue("incrementValue", incrementValue);

    Hope this helps.

    Regards,
    Rohit Shingalapur
    http://www.developerscorner.co.cc