You need to make sure the classpath contains
- Your JAR
- The JUnit JAR
You can set the class path by using the -cp
flag to the java
command. Then you can use junit.textui.TestRunner to run the tests.
If you're using Linux (note the use of :
as the path separator between jars)
java -cp /path/to/my.jar:/path/to/junit.jar junit.textui.TestRunner com.mypackage.MyClassWithUnitTests
If you're using Windows (note the use of ;
as the path separator between jars)
java -cp /path/to/my.jar;/path/to/junit.jar junit.textui.TestRunner com.mypackage.MyClassWithUnitTests