Sam has posted 7 posts at DZone. View Full User Profile

Performance Testing Can Be as Simple as Unit Testing.

  • submit to reddit

The first tool that comes in to mind when someone wants to do performance testing of Java server side applications is JMETER. It's free, opensource, and one of the best lightweight stable products to automate the performance/load testing.

Maven is another fantastic tool that helps to manage dependecies and build management. As we already know, maven takes care of running all our unit tests as part of a build.

Why not run your performance tests for every build to see if there is any bottleneck in performance?

If you are already familier with the JMeter and creating the test script file(.JMX file) for your application using jmeter, then it is as simple as compiling a Java project.

If you are not familier with JMeter then it is advisable to know this first:


(1) Add the following plug-in your pom.xml file















 (2) Keep the performance JMeter's test script files in yourprojectdirectory/src/test/resources/jmeter/ directory.

 (3) Run the maven command:  mvn clean install

 (4) That's all, the maven command build, run the unit tests and then run the performance tests based on the scripts placed in src/test/jmeter/ directory.

 (5) Basic report (including success, failures, average response time, min and max response timings) in reports directory.

Published at DZone with permission of its author, Sam Kyatham.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Peter Lawrey replied on Thu, 2013/03/07 - 1:34pm

You can also time your unit tests by taking the System.nanoTime() at the start and end and have them fail if they take too long, or are too short.

Caspar MacRae replied on Fri, 2013/03/08 - 8:02am in response to: Peter Lawrey

Or just use

@Test(timeout = 1000)

in Junit 4x.

I like the idea of a test being too short  =)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.