Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a simple JMeter script

I need to write a script that does the following (doesn't matter to which website, I am only doing this to learn and practice):

  1. Simulates HTTP requests (method: get)
  2. Reads parameters from a document and uses them in the script
  3. Saves an expression from the response of the request and uses it as a parameter in the next request
  4. Saves the output to a file

After a few hours of reading the documentation and watching some video tutorials, I can manage step 1 easily. I have a little idea on how to do steps 2 and 4 though there might be a chance that I am not doing them efficiently. And unfortunately I have no idea how to do step 3.

Can someone help me in doing those steps please or at least give me some good links to tutorials that may help me out (I've found the official manual too confusing)?

Here are some links I used to learn this tool: For step 1 and for step 2 they helped a little but more guidance is welcomed.

like image 473
r3x Avatar asked Nov 24 '12 19:11

r3x


People also ask

What are JMeter scripts?

What Is a JMeter Script? A JMeter script allows you to record actions a user would take in your application.


1 Answers

The best sources of Jmeter documentation I know about are in Documentation section at JMeter website: user manual and best practices (for starters), Component Reference and Functions reference (once you are comfortable with basic Jmeter capabilities).

Especially you should read 4th, 5th and 6th sections of User Manual that will give you answers to those and many other questions that you'll have.

Nevertheless I should give answers by myself:

  1. Use HTTP Request Sampler
  2. Use CSV Data Set Config
  3. Use PostProcessor. I guess the most helpful will be Regular Expression Extractor that will extract data to variable and then you can use this variable as ${variable} in your test
  4. I guess you mean test results by output. If this is case, use Listeners. In my experience the most helpful listeners are Simple Data Writer, View Results Tree (only for debugging), Response Latencies over Time from Jmeter plugins. Note that only Simple Data Writer should be enabled when you'll eventually run your test against SUT to minimize resources usage.

Once you are comfortable with JMeter capabilities note that some useful functionality is absent in it but exists in JMeter plugins:

  • Response Latencies Over Time listener
  • thread groups for better control
  • Non-GUI Console Status Logger (helpful when running your tests)
like image 152
Andrei Botalov Avatar answered Oct 07 '22 13:10

Andrei Botalov