Jmeter can be used to do performance testing of an application that has existing selenium scripts written over Junit.
- The samplers in Jmeter have a category known as “Junit Request”, which can be used to execute tests written in Junit3 or Junit4
- A test script written in Junit 3 extends the “TestCase” class of Junit, here is an example of the test script written using the “TestCase” class.
Image may be NSFW.
Clik here to view.
- A test script written in Junit 4 uses Junit annotations, here is an example of the test script written using Junit annotations
Image may be NSFW.
Clik here to view.
- Once the scripts are in place, export them into jar files. To export to jar files right click on the project folder -> Select Export-> Expand Java folder -> Click on Jar files -> Click Next -> -> Select the resource to export -> Check the option “Export Java source files and resources” -> Select the export destination -> Finish
- Copy the jar file and paste it in the junit folder under lib folder of Jmeter. Here is the path where I have placed the jar files in my system: “D:\apache-jmeter-2.9\apache-jmeter-2.9\lib\junit”
- Download the selenium server standalone jar “http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.24.1.jar&can=2&q=”
- Copy the selenium server standalone jar to the lib folder of Jmeter
- Now open Jmeter, create a “Thread Group” [ Right click on the Test Plan -> Select Add – > Select Thread(Users) -> Select Thread Group
- Create a “Junit Request” [Right click on Thread Group -> Select Add -> Select Sampler -> Select Junit Request
- In the Junit Request sampler, there would be two drop downs named “Classname:” and “Test Method”
Image may be NSFW.
Clik here to view.
In the two drop downs one could see the tests that were created using Junit3 i.e by extending the TestCase class
- In order to see the tests that were created using Junit annotations, just check the checkbox saying “Search for Junit4 annotations” and the drop downs would populate accordingly
- Add a listener [Right click on Thread Group -> Select Add -> Select Listener (One can select the type of listener as desired , say “View Results in Table”/ “View Results in Tree”/”Summary Report”
- Select the test that you want to execute from the “Test Method” drop down and run the test
- It will launch the browser and perform the action as per one’s test.
- The time taken by each sampler could be noted from the results shown in “View Results in Table” and the Standard Deviation, Throughput, Mean, Average, Minimum Maximum time the samples took to execute could be noted from the “Summary”/”Aggregrate” reports
Written By: - Jaya Mohanty, QA Engineer, Mindfire Solutions
Image may be NSFW.
Clik here to view.

Clik here to view.
