Question

I have, a few JMeter scripts, which make HTTP calls to test my own web service, written in Spring. I would like the JMeter scripts to be automatically executed for every build and test if the build is good. So, as suggested at:- http://ribblescode.wordpress.com/2012/04/16/how-to-run-jmeter-tests-with-maven/ I have set up my Maven .pom files of my Spring web service project to have the Jmeter plugin stuff defined. And, I have added my JMeter scripts to src/test/JMeter. Now, I use Eclipse as my IDE and when I have my project already running on Tomcat from within Eclipse (Run As-> Run on Server) and then do Run As->Maven Install on my project with this setup, it executes the JMeter scripts and works as intended. However, if my web service is not already running on Tomcat, the Maven build fails as the JMeter is not able to successfully make the HTTP calls. Now, my problem is that this setup means the JMeter script is actually making calls to the old build which is already running and not on the new build which was generated when I clicked on Run As-> Maven Install at that point in time.

So, given this scenario how do I have it so that, when I make some code change, and then do a new build using Maven, it first deploys it and then runs the JMeter script on this new build?

Was it helpful?

Solution

Maven is not intended to test the Tomcat running in your Eclipse. Jmeter is an integration test tool, so all you have to do is to haang the appropriate plugins on the appropriate maven lifecycle phases. You actions needed:

pre-integration-test phase steps

  1. download and unzip Tomcat
  2. deploy your packaged webapp
  3. start tomcat

integration-test phase step

  1. Download and unzip Jmeter (for example with maven-dependency-plugin)
  2. run jmeter tests

post-integration-test phase

  1. stop tomcat

Thats all you need. One tool to use could be the Cargo Maven Plugin, which helps you in deployment, start and stop.

An example is here http://www.alexecollins.com/content/jmeter-integration-test-template-pom/

If you are interested, it is also possible to collect coverage info for your JMeter tests: http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top