My Blog List

Thursday, December 22, 2011

JMeter - Beginner's Tutorial

This is a basic tutorial explains how to start with JMeter and how to use for basic load testing. Also it covers a flow which is mostly used across industries.
You can get lot of clear help here. JMeter Help

JMeter supports HTTP, HTTPS, FTP, SOAP and LDAP and it can be Integrated with selenium to do extensive use. Here are the flow to start your Load Testing.


Creating Tests:
1. First, Add Proxy (Under Workbench >> Non-Test Elements). This Proxy only acts as a recorder.
So don't forget to start the proxy before recording. Also after finished recording, stop the Proxy.


2. Add Controller. (Under Workbench >> Logic Controllers >> Simple Controller). This Controller is nothing but a container(mainly used for grouping). Inside a controller you can have your requests. ie. Transactions


3. Now record your transaction and drag it under your controller.


4. Add ThreadGroup (Under TestPlan) and group the recorded requests(or controllers) under thread group. Its for grouping set of controllers to run. ThreadGroup will contain users, ramp up and etc which are used to virtualize load while running.


5. Add listeners. (Workbench >> Listeners >> Assertions >> Comparison Assertion Visualizer). Listeners are needed to RUN, otherwise you can't view the results. Listeners are like runner here. You can select any kind of listener based on requirement.
Comparison Assertion Visualizer  -- will show results pass or fail for each request.
Save Response to File  -- will save response to external html file.


Assertions:
6. Add assertions for specified request. (Ex. Response Assertion is used to verify some text is present or not).
That's all. Now script is ready. So lets start your load test now.


Running:
1. Go to your Thread Group
2. Set No.Of. Threads(Users)Ramp Up Period and Loop Count.
3. Start Run and see the results on your listener.


Data-Driven:
We can feed data from CSV file or extract data from previous response and feed that to a request.


7. We can feed data from CSV file.
     - Just keep a CSV file with only data but not with column names.(separated by any delimiter)
     - Add "Config Element >> CSV Data Set Config"
     - Set FileName and ColumnNames (CSV contains no column names, just data. So you need to mention your column names ie.Variable Names here separed by delimiter)
     - On Request, Pass value as ${VariableName} ie. Column Names specified in above step.


8. Data Correlation ie. Extract data from previous page's response and put it as data for next request or page transaction.
    - Do "Listeners >> Save Response to file" for previous request.
    - Then find the format of expression in response for the part containing our data to be extracted.
    - Then on the request, add "Post Processors >> Regular Expression Extractor" to extract the data.
    - Set Reference Name, Expression (like productID=(.*?) ) and template as $1$ (template is used to extract multiple values. Here going to extract 1 string only. If its two values, then $1$$2$)
   - Then for the next request, set this reference name as value like ${refName}

Hope this discussion will give you some idea on how to work with JMeter !!!

3 comments:

  1. Thank you, Shanmugavel, for good post, it is helpfull for beginners. In addition I can share a portion of JMeter Tutorials and articles:
    http://community.blazemeter.com/knowledgebase/topics/10018-jmeter-tutorials
    http://blazemeter.com/blog

    ReplyDelete
  2. Excellent Post. Also visit http://whiteboxqa.com/#performance.php

    ReplyDelete
  3. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete