【转】What CLASSPATH settings are needed to run JUnit?

来源:互联网 发布:cn域名注册 编辑:程序博客网 时间:2024/06/03 09:39

(Submitted by: Eric Armstrong)

To run your JUnit tests, you'll need the following elemements in your CLASSPATH:

  • JUnit class files
  • Your class files, including your JUnit test classes
  • Libraries your class files depend on

If attempting to run your tests results in a NoClassDefFoundError, then something is missing from your CLASSPATH.

Windows Example:

set CLASSPATH=%JUNIT_HOME%\junit.jar;c:\myproject\classes;c:\myproject\lib\something.jar

Unix (bash) Example:

export CLASSPATH=$JUNIT_HOME/junit.jar:/myproject/classes:/myproject/lib/something.jar

2. run command

java org.junit.runner.JUnitCore org.junit.tests.AllTests

example: java org.junit.runner.JUnitCore com.google.example.LoginGoogle