Friday, February 13, 2015

Record and Run in JMeter for Performance Test

JMeter is an open source desktop application available for all. By using Apache JMeter we can perform performance test on a web application. A very short, simple and quick intro available, if you want to check the link.

In this post we will learn how to record a test scenario and run it in Windows. Follow step by step process as describe below,
  • Download Apache JMeter.
  • Download Java. And install it.
  • Unzip Apache JMeter file. And open jmeter.bat.
  • Add users by right clicking on the Test plan. Test plan-> Add-> Threads (Users)-> Thread Group.
  • Add Thread group name, Number of threads, Ramp up period and Loop count. Remember in JMeter Thread meaning User. Replace thread word with user. Add User group name, Number of users and others. Ramp up period in sec = Ramp up period/ Number of users. Loop count can be forever also. If you use forever loop than you have manually stop the test.
  • Go to WorkBench section.
  • Right click on Workbench. Add-> Non-Test elements-> HTTP(S) Test Script Recorder.
  • Use the Start button at bottom right corner to start recording. And Stop after recording is done.
  • In your Mozilla Firefox driver go to Options-> Networks-> Manual proxy. Add localhost in your server field and 8080 in the port number field.

  • Add Recording controller. 
  • Right click on the Thread group. Add-> Logic controller-> Recording controller.
  • Perform the test scenario in the browser.
  • After finishing the scenario hit the Stop button in HTTP(S) Test Script Recorder of JMeter.
  • Observe that all test steps are added in Recording controller under the Thread group as HTTP requests.
  • To view performance results we need to add a report. Listener is report/ output in JMeter.
  • Right click on Thread group. Add-> Listener-> Summary report.
  • It is a good practice to clear your previous records before saving the test plan. Try to do it every time you save. 
  • Save your test plan and hit the play button.
  • By hitting the play button you are saying to JMeter, run the recorded test for 50 users. 1 user will be added every second. Running the loop 5 times, that will be 50*5 times for all users.
  • After test run process is finish check the Summery report for test data.
Please leave a reply, about this article was helpful or not? Suggestions of improvements are also welcome. Thanks for your time.