Jmeter for Performance Testing
We all agree how important functional automated testing is, however not many applications go through a complete round of performance testing. Here are some of the reasons why everyone should make Performance testing an integral part of their software development process.
– Capacity Planning
– Scalability & Stability
– Average online shopper expects your site to load in 2 seconds
– Consumers will not wait for more than 3 seconds fro a page to load
– Revenues lost due to poor performing applications
There are a ton of tools and services that are available to meausre your application performance, but we will be talking about Jmeter and it’s concepts.
– Open Source – no licensing cost
– Portable. Runs on any OS that supports Java
– Easy to use (little or no Programming)
– Very Large user community, easy to find answers to questions.
– Can be integrated with any CI tool
– Can be extended to fit your needs.
– JSR232 support
– Can be easily scaled to test large scale applications.
Steps for designing a succesful load test
- Record a transaction using the proxy
- Save the recorded session as a thread group
- Modify or update the samples to handle dynamic content
- Add other necessary config elements to the test plan.
- Setup duration and number of threads/Users to simulate
- Add listeners to view results
This will be a series of blog posts of various techniques on performance testing using jmeter. In this post I will walk you through how to get started and record your first script.
– The only prerequisite is java, so make sure you have the most recent version of Java installed
– Download the binaries from the apache Jmeter’s site (http://jmeter.apache.org/)
– Extract the archive and extract to a folder
– There are scripts in the bin folder which you can use to open the Jmeter UI
– If you are using a Mac or Linux desktop you will need to make the jmeter.sh is executable (chmod +x jmeter.sh)
– Running the jmeter.sh or the jmeter.bat file will open up the Jmeter GUI.
To record your first script right click on the workbench -> add -> Non Test Elements -> Http Test Script Recorder
There are various options to choose when you are recording a transaction. I feel the best option to chosse is “Store 1st Sampler”. This option helps us record just the first request and is more than sufficient to simulate the intended action. You can leave the rest of the options as is.
Click the Start button and your Jmeter Recorder is ready to start capturing http traffic. Now setup a browser to use port 8080 as a proxy. You can do that by going to your browser network settings and entering localhost:8080 for you proxy. Navigate to any application using that browser instance and you should see samplers being captured under the HTTP test script recorder
Add a new thread group under your Test Plan and drag and drop all the recorded samples to your newly created thread group.
This is just a very basic test. Feel free to click the Green arrow and run it but you will not see much as there are no listeners added. In the next post I will show you how to edit a thread group to handle dynamic content and also how to debug the scripts.