JUnit测试在CLI等效

编程入门 行业动态 更新时间:2024-10-20 11:52:26
本文介绍了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?

推荐答案

看看这个页面: 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等效

本文发布于:2023-11-30 04:19:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648697.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   JUnit   CLI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!