Step by step
Using tests in Jar files
Contents:
Preamble
Tests are distributed as jar files. The procedure to run tests
and fix possible problems is as follows:
Note: This procedure has been tested with Eclipse 3.2
Import Jar file
Attach source code
Up to now it is possible to run the tests but is not possible to look at the test code, which is required
to fix the errors possibly revealed by the tests.
You need to associate the source code to the class files:
- Right click on the .jar file and chose Properties, the properties window appears:
- Select Java Source Attachment then click on Workspace...
- Select the .jar file in the current project and click on OK and the again on OK
in the properties window.
- Now the icon should have been changed into
and double-clicking on any class in the .jar file you should be able to see the source code.
Run tests
After the previous set-up it is possible to run the tests.
- Expand the jar and the packages contained in it
by clicking on the '+' simbols until you locate the AllTests class.
- Right click on the class (AllTests.class), select Run As then
if it is present chose Junit Test otherwise select
.
- I the latter case the Run profile dialog should appear:
- Then double click on the JUnit item (a new run profile is created) and then click Run
- The Junit tab should appear on the left with the result of the tests.