Skip to main content

Benchmarking using Japex and JUnit

Posted by spericas on January 26, 2006 at 2:16 PM PST

Despite some similarities, performance testing and conformance testing are different types of activities, and certainly not every conformance test is necessarily a good performance test. There have been some attempts to using JUnit for performance testing, notably JUnitPerf. Rather than extending a conformance framework for performance purposes, we took the opposite approach and extended Japex, a performance framework, to integrate with JUnit. It turns out that in some cases JUnit tests are good performance tests and having the ability to re-use conformance tests for performance does save a lot of time.

A new Japex driver for JUnit is now part of the Japex Driver Standard Library (JDSL), and is located in the package com.sun.japex.jdsl.junit. This new driver, JUnitDriver, accepts the test case parameters testName and methodName. The latter can be omitted in which case the entire test suite pointed by testName will be executed. Here is a sample configuration file, also included as part of the Japex set of samples:

  <testSuite name="JUnit Sample" xmlns="">
      <driver name="JUnitDriver">
          <param name="japex.driverClass" value="com.sun.japex.jdsl.junit.JUnitDriver"/>
          <param name="description" value="JUnit Driver"/>

      <testCase name="testHello">
          <param name="testName" value="JUnitSuite"/>
          <param name="methodName" value="testHello"/>
      <testCase name="testBye">
          <param name="testName" value="JUnitSuite"/>
          <param name="methodName" value="testBye"/>
      <testCase name="testHelloAndBye">
          <param name="testName" value="JUnitSuite"/>

This Japex configuration file defines three test cases to run the testHello method, the testBye method followed by the entire JUnitSuite suite (i.e., the testHello and the testByte methods again in this sample). A JUnit TestRunner is used in the last test case to run the entire test suite, unfortunately this also prints some information to standard output which I haven't been able to redirect, yet.

Well, I hope you find this useful, time will tell if this is the right way to integrate JUnit into Japex. For now, I think we need to try this out a bit more, and as always we welcome your feedback at Happy benchmarking!

Related Topics >>