Run JUnit tests automatically in Jenkins without maven or ant(在 Jenkins 中自动运行 JUnit 测试,无需 maven 或 ant)
问题描述
我目前正在使用 Jenkins 设置持续集成工具.我想在每次构建时运行 JUnit 测试.我的问题是,将要测试的项目都没有使用 maven 或 ant.所以我想知道是否可以在没有 maven 或 ant 的情况下运行这些测试,如果可以,我该怎么做?
I am currently setting up a continuous integration tool with Jenkins. I would like to run JUnit tests everytime a build is made. My problem is that none of the projects that will be tested use maven or ant. So I would like to know if it is possible to run these tests without maven or ant, and if it is, how do I do it ?
提前感谢您的回答
推荐答案
你试过 ClasspathSuite 由 Johannes Link 撰写?
Have you tried ClasspathSuite by Johannes Link?
来自文档:
机制很简单.只需在 Eclipse 中创建一个新项目并添加所有包含要运行到其构建路径的测试的项目.现在创建一个这样的类:
The mechanism is simple. Just create a new project in Eclipse and add all projects that contain tests you want to run to its build path. Now create a class like that:
import org.junit.extensions.cpsuite.ClasspathSuite;
import org.junit.runner.RunWith;
@RunWith(ClasspathSuite.class)
public class MySuite {}
这将执行所有 JUnit4 测试类(那些包含方法的带有@Test 注释)在项目类路径中.
This will execute all JUnit4 testclasses (those containing methods with the @Test annotation) in the projects classpath.
然后您可以使用 JUnitCore.
java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name]
有关详细信息,请参阅 如何从命令行运行 Junit 测试用例?.
For more information, see How to run Junit testcases from command line?.
这篇关于在 Jenkins 中自动运行 JUnit 测试,无需 maven 或 ant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Jenkins 中自动运行 JUnit 测试,无需 maven 或 a


- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 转换 ldap 日期 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 获取数字的最后一位 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01