The Artima Developer Community
Sponsored Link

Running JUnit Tests with Artima SuiteRunner
by Bill Venners
February 17, 2003

<<  Page 5 of 7  >>


Changing the Runpath to Run Your Existing JUnit Test Suite

In the previous step, you used Artima SuiteRunner as a JUnit runner to run the example JUnit test suite included in the Artima SuiteRunner distribution. Now I'll show you how to use Artima SuiteRunner to run your own existing JUnit test suite. To do so, you must edit the recipe and change the runpath and suites list.

To edit the runpath, select File-->Edit Recipe and click on the Runpath tab. The Runpath tab's dialog should still show the example directory and the junit.jar file. To run your existing JUnit test suite, you must keep junit.jar in the runpath, but you can get rid of the example directory. To remove the example directory from the runpath, click on example and press the Remove button, as shown in Figure 7.

Figure 7. Removing example from the runpath.

After pressing the Remove button, only junit.jar remains in the runpath, as shown in Figure 8.

Figure 8. The example directory is no longer in the runpath.

At this point, you must add to the runpath all JAR files and directories needed by JUnit to run your existing test suite. If you use JUnit's Swing runner, for example, you will likely need to add to the runpath all the files and directories that appear in the classpath when you run JUnit. To load classes for your existing JUnit test suite, Artima SuiteRunner will create a URLClassLoader that will look in each JAR file and directory in the order they appear in the runpath.

In my case, I have a JUnit-based conformance test suite for the ServiceUI API sitting in the directory /Users/bv/projects/scslsrc/serviceui. (This is the very JUnit test suite that gave me sufficient frustration that I went off and started writing what eventually became Artima SuiteRunner, as described in Why We Refactored JUnit.) Because both the classes that make up the ServiceUI API conformance test suite and the ServiceUI API classes being tested can be loaded from the /Users/bv/projects/scslsrc/serviceui directory, all I need to do is to add the /Users/bv/projects/scslsrc/serviceui directory to the runpath. To add this directory, I press the Select button on the Runpath tab's dialog, navigate to the /Users/bv/projects/scslsrc directory, select serviceui, and press the Choose button, as shown in Figure 9.

Figure 9. Selecting the serviceui directory to add to the runpath.

As shown in Figure 10, my runpath now includes junit.jar and the directory from which Artima SuiteRunner can load both the class files for the JUnit-based ServiceUI API conformance test suite and the actual ServiceUI API classes they test.

Figure 10. The serviceui directory is now in the runpath.

<<  Page 5 of 7  >>

Sponsored Links

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us