views:

2300

answers:

2

What's the best strategy to use when writing JMeters tests against a web application where the values of certain query-string and post variables are going to change for each run.

Quick, common, example

  1. You go to a Web Page
  2. Enter some information into a form
  3. Click Save
  4. Behind the scenes, a new record is entered in the database
  5. You want to edit the record you just entered, so you go to another web page. Behind the scenes it's passing the page a parameter with the Database ID of the row you just created

When you're running step 5 of the above test, the page parameter/Database ID is going to change each time.

The workflow/strategy I'm currently using is

  1. Record a test using the above actions
  2. Make a note of each place where a query string variable may change from run to run
  3. Use a XPath or Regular Expression Extractor to pull the value out of a response and into a JMeter variable
  4. Replace all appropriate instances of the hard-coded parameter with the above variable.

This works and can be automated to an extent. However, it can get tedious, is error prone, and fragile. Is there a better/commonly accepted way of handling this situation? (Or is this why most people just use JMeter to play back logs? (-;)

+1  A: 

We have had great success in testing similar scenarios with JMeter by storing parameters in JMeter Variables within a JDBC assertion. We then do our http get/post and use a BSF Assertion and javascript do complex validation of the response. Hope it helps

Useful info, thank you!. However, part of what bothers me is/was the "complex validation". My instincts say you'd gain an amount of test coverage, but maintaining those complex validations would eat away any benefit the coverage brought. Do you find that is/isn't the case?
Alan Storm
+1  A: 

Sounds to me like your on the right track. The best that can be achieved by JMeter is to extract page variables with a regular expression or xpath post processor. However your absolutely correct in that this is not a scalable solution and becomes increasingly tricky to maintain or grow.

If you've reached is point then you may want to consider a tool which is more specialised for this sort of problem. Have a look web testing tool such as Watir, it will automatically handle changing post parameters; but you would still need to extract parameters if you need to do a database update but using Watir allows for better code reuse making the problem less painful.

MattChurchy
I haven't tried Watir, but what he describes is pretty much exactly the technique I've found to work well for jmeter. No long term maintainability data, but I'm mainly worried about authenticity_token in Rails apps, which isn't going to change too much.
edebill