tags:

views:

630

answers:

3

Hi all,

I have a J2EE application that needs some extensive integration testing. I am using Jmeter to generate HTTP POST requests. So far I manage to send them to the server correctly but the xml is static.
I am looking for a way to insert dynamic/random values into the XML and then send it to the server. Something like a PreProcessor but I am not sure how it is done.

Can anyone provide:
1. JMeter tutorials?
2. How to generate dynamic/random xml content to HTTP request
3. JMeter examples

Many thanks,
Gadi.

A: 

Hi there!

JMeter guidelines strongly recommend to use pre-generated data to have good perfomance and accuracy.

The task could be done via CSV Data Set Config component (Best Practices, section 16.5). The main idea is to generate a big test data set, save it to text file and then use as params in request template (line of CSV file per request). One can put whole request as one and only param if s/he wish.

Please be noted that JMeter 2.3.4 (latest version atm) has some restrictions:

  • it doesn't understand multiline values (though such ones supported by CSV standard itself), so escaping might be required;
  • it doesn't understand column names, so it is possible to associate variables by column position only (not by logical name unfortunately).

Thanks, Maksim

Maksim Liauchuk
Many thanks Maksim.What are the tools available to generate the XML out of your suggested csv file?Lets say I have 10 different parameters to insert into an xml and I can read them from the csv file.Many thanks.
Gadi
You're welcome, Gadi. I guess, once you need to send an XML then some SOAP/XML-RPC sampler is to be used. In such a case, all you need is just put a template with params into SOAP-XML-RPC Data field.<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:SomeActionRequest xmlns:ns2="urn:some:namespace"><ns2:Param1>${paramFirst}</ns2:Param1></ns2:SomeActionRequest></soapenv:Body></soapenv:Envelope>If you're limited with plain HTTP, then XML is to be sent as a get/post param, right? Then just add params to your HTTP Request sampler.Cheers.
Maksim Liauchuk
A: 

hey Gadi

you can insert dynamic or random data into the XML using __Random and __char functions nested in the XML.

So that everytime an xml is posted, the values will be random.

basically, just define your xml structure and use the __random and __char functions nested in each other to randomly create any random text/numbers. Then use the __time function to generate date/time data.

i've got a working example with jmeter, but it's going to cost you. :)

Duy

Duy
A: 

Another approach to test web-application is use of automated recording tools like Badboy to record steps that you wanted to test with your web application. Then you can pass the same script to Jmeter for testing purpose.

You can also pass different values to parameters within script to test different scenarios. For eg.Your application is having 'Login page' with username/password field. Then you can record the script in case of 1)valid and 2) invalid login credentials.

Then during testing you can pass different values through CSV or by modifying some values directly in recorded script.

You can find more information about Badboy at http://www.badboy.com.au/

lucentmind