Java Reference
In-Depth Information
The JDK installation directory has a subdirectory named jre/lib/ext .
Don't put the JUnit JAR file in there. If you have followed our instructions,
you're OK, since we had you create a new directory.
To use JUnit, the junit.jar file needs to be in your classpath. For
example:
$ export CLASSPATH="${CLASSPATH}:${HOME}/junit/junit3.8.1/junit.jar"
That's all the installing there is. It doesn't feel like much, because you
haven't done much. All it provides is a JAR file that you will use when you want
to run tests. That's where it gets interesting.
13.4.2
To test out your installation, cd to the directory where you unpacked JUnit.
If it isn't already part of it, add the current directory (“ . ”) to your CLASSPATH :
Using JUnit
$ export CLASSPATH="${CLASSPATH}:."
Then try:
$ java junit.swingui.TestRunner junit.samples.AllTests
You should see a Java Swing GUI appear, with a green bar showing the
progress of the testing (Figure 13.3).
NOTE
You may see an error message like this in your terminal window:
(data/time) java.util.prefs.FileSystemPreferences checkLock...
WARNING: Could not lock System prefs.Unix error code 136742412
(data/time) java.util.prefs.FileSystemPreferences syncWorld
WARNING: Couldn't flush system prefs: java.util.prefs.Backi...
It will keep repeating as long as JUnit's GUI is running. The easiest fix is
to make the jre directory world-writable while you run the GUI the first time. It
will create the files it needs (in a directory, .systemPrefs ), and thereafter
stop pestering you. Remember to change permissions on the directory back to
their original value.
Search WWH ::




Custom Search