Getting Started
The latest version of JUnit is available on SourceForge.
- First, download the latest version of JUnit, referred to below as
junit.zip
. - Then install JUnit on your platform of choice:
Windows
To install JUnit on Windows, follow these steps:
- Unzip the
junit.zip
distribution file to a directory referred to as%JUNIT_HOME%
. - Add JUnit to the classpath:
set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar
To install JUnit on Unix, follow these steps:
- Unzip the
junit.zip
distribution file to a directory referred to as$JUNIT_HOME
. - Add JUnit to the classpath:
export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit.jar
- Unzip the
- (Optional) Unzip the
$JUNIT_HOME/src.jar
file. - Test the installation by running the sample tests distributed with JUnit. Note that the sample tests are located in the installation directory directly, not the
junit.jar
file. Therefore, make sure that the JUnit installation directory is on your CLASSPATH. Then simply type:
java org.junit.runner.JUnitCore org.junit.tests.AllTests
If the tests don't pass, verify thatjunit.jar
is in the CLASSPATH. - Finally, read the documentation.
- Delete the directory structure where you unzipped the JUnit distribution.
- Remove
junit.jar
from the CLASSPATH.
Nessun commento:
Posta un commento