在没有maven或ant的Jenkins中自动运行JUnit测试 [英] Run JUnit tests automatically in Jenkins without maven or ant

查看:940
本文介绍了在没有maven或ant的Jenkins中自动运行JUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Jenkins设置一个持续集成工具。我想在每次构建时运行JUnit测试。我的问题是,没有一个项目将被测试使用maven或蚂蚁。所以我想知道如果没有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 by 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 运行它。 / p>

You can then run it using JUnitCore.

java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name]

有关详情,请参阅如何从命令行运行Junit测试用例?

这篇关于在没有maven或ant的Jenkins中自动运行JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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