13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

13.4 Installing and Running JUnit301The JDK installati<strong>on</strong> directory has a subdirectory named jre/lib/ext.D<strong>on</strong>’t put the JUnit JAR file in there. If you have followed our instructi<strong>on</strong>s,you’re OK, since we had you create a new directory.To use JUnit, the junit.jar file needs to be in your classpath. Forexample:$ export CLASSPATH="${CLASSPATH}:${HOME}/junit/junit3.8.1/junit.jar"That’s all the installing there is. It doesn’t feel like much, because youhaven’t d<strong>on</strong>e much. All it provides is a JAR file that you will use when you wantto run tests. That’s where it gets interesting.13.4.2 Using JUnitTo test out your installati<strong>on</strong>, cd to the directory where you unpacked JUnit.If it isn’t already part of it, add the current directory (“.”) to your CLASSPATH:$ export CLASSPATH="${CLASSPATH}:."Then try:$ java junit.swingui.TestRunner junit.samples.AllTestsYou should see a Java Swing GUI appear, with a green bar showing theprogress of the testing (Figure 13.3).NOTEYou 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 syncWorldWARNING: Couldn't flush system prefs: java.util.prefs.Backi...It will keep repeating as l<strong>on</strong>g as JUnit’s GUI is running. The easiest fix isto make the jre directory world-writable while you run the GUI the first time. Itwill create the files it needs (in a directory, .systemPrefs), and thereafterstop pestering you. Remember to change permissi<strong>on</strong>s <strong>on</strong> the directory back totheir original value.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!