我写了一些不完全有主要方法的代码。但我想知道代码是否有任何问题。基本上,我可以使用Eclipse中的JUnit测试用例(我使用linux)。但我处在一种情况,我必须在Windows中测试它目前没有Eclipse。所以我留下的选项,在cmd(如果这是可能的)。
I have written certain code which doesn't exactly have a main method. But I want to know if the code has any issues. Basically I can do it using the JUnit test case in Eclipse (I am using linux). But I am in a situation where I have to test it in Windows which currently doesn't have Eclipse. So I'm left with the option of doing it in cmd (if that is possible). What is the JUnit test (Eclipse) equivalent in cmd?
推荐答案看看这个页面: junit.sourceforge/doc/faq/faq.htm#running_4
要运行JUnit测试,您需要在中的CLASSPATH中包含以下元素:
To run your JUnit tests, you'll need the following elemements in your CLASSPATH:
- JUnit类文件
- 您的类文件,包括您的JUnit测试类
- li>
- JUnit class files
- Your class files, including your JUnit test classes
- Libraries your class files depend on
如果尝试运行测试导致NoClassDefFoundError,,那么CLASSPATH中缺少某些内容。
If attempting to run your tests results in a NoClassDefFoundError, then something is missing from your CLASSPATH.
Windows示例:
Windows Example:
set CLASSPATH=%JUNIT_HOME%\junit.jar;c:\myproject\classes;c:\myproject\lib\something.jar调用程序:
java org.junit.runner.JUnitCore< test class name>
更多推荐
JUnit测试在CLI等效
发布评论