JUnit测试在CLI等效 [英] JUnit test equivalent in CLI

查看:192
本文介绍了JUnit测试在CLI等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些不完全有主要方法的代码。但我想知道代码是否有任何问题。基本上,我可以使用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?

推荐答案

看看这个页面:
http://junit.sourceforge.net/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等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆