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.zipdistribution 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.zipdistribution 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.jarfile. - 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.jarfile. Therefore, make sure that the JUnit installation directory is on your CLASSPATH. Then simply type:
All the tests should pass with an "OK" message.java org.junit.runner.JUnitCore org.junit.tests.AllTests
If the tests don't pass, verify thatjunit.jaris in the CLASSPATH. - Finally, read the documentation.
- Delete the directory structure where you unzipped the JUnit distribution.
- Remove
junit.jarfrom the CLASSPATH.
Nessun commento:
Posta un commento