A good performance is one of the main goals of any software projects. Taking that into account, chances are that you'll eventually end up doing some performance testing. For web pages, this is critical. If an online application have performance problems, this will have an important impact on the user experience.
So, in this article I'll show how to create a basic test case with JMeter, a performance testing tool by Apache.
- JMeter is a java application, so you need Java installed. Download it here.
- Apache JMeter. Download it here.
1. Extract the .zip or .tgz file. I extracted mine to C:\jmeter.
2. Go to that path and you should see the apache-jmeter-3.0 folder.
Running your first test script
1. Open the JMeter path > bin.
2. Double click jmeter.bat. The JMeter UI will be displayed.
3. Each test plan (which is a a series of steps JMeter will execute when run) can be saved as a .jmx file. So, for this first example, we can use one of the sample scripts that come with JMeter. So, go to File > Open.
4. Double click 'examples' and select CSVSample.jmx.
5. Click 'Open'. The file will be loaded in the left pane of the dashboard.
6. Finally, to run this script, press Start.
7. You won't see much happening, but click 'View Results in Table' and you'll see the test results:
Creating a test plan
Now we will create our own test plan. This will be a simple plan, just to show you how you can construct more complex Test Plans once you got familiarized with JMeter.
1. Click 'New'.
2. If you don't want to save the current items, click No.
3. Enter a name for the test plan. I'll call mine 'Testools Test Plan'
4. Right click Testools Test Plan > Add > Threads (users) > Thread Group.
5. Right click Thread Group > Add > Sampler > HTTP Request. This will add an element that will allow us to do a GET request to a page:
6. In 'Server Name or IP' enter www.testools.net. We will do a simple GET request to the Testools page in this step.
7. Now we need to add a listener. This will catch the results and display them. Right click Thread Group > Add > Listener > View Results Tree.
8. Save the Test Plan. To do that, go to File > Save. Select a folder and enter a name for the file. In this case, I'll call it TestoolsTestFile.jmx, and I'll save it at C:\jmeterScripts. Then click Save.
9. Press Start.
10. The test won't take long. Notice that a new item was created in 'View Results Tree', in the left pane. Click it to see the details:
And that's it! You can add more elements to the Thread Group to achieve your testing goals. In future articles I'll cover more of the functionality of JMeter, but this should be enough to get you started.