如何设置詹金斯使用JUnit [英] How to setup Jenkins with Junit

查看:184
本文介绍了如何设置詹金斯使用JUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个JUnit测试套件,我们通常从Eclipse中运行。最近,我们开始了努力,以获得更好的发展环境的过程。作为其中的一部分,我们已经开始建设我们的詹金斯项目。我们也想,如果有可能我们的构建过程中运行JUnit测试套件。要做到这一点,我认为我们需要一种方法来执行命令行测试套件,使我们可以在詹金斯它们整合和分析它们的输出。

We have a JUnit test suite that we usually run from eclipse. We have recently started a process of trying to get a better development environment. As part of this we have started building our project in Jenkins. We would also like it if it was possible to run the JUnit test suite during our build. To do this I think we need a way to execute the test suite from command line so that we can integrate them in Jenkins and parse their output.

我们如何建立詹金斯来运行我们的测试?

How can we set up Jenkins to run our tests?

推荐答案

您可以创建一个的JUnit 您的构建过程中Ant任务,让詹金斯运行任务

You could create a junit ant task during your build and let Jenkins run that task

下面是我们在一个项目中使用的一些线路。这里推出了一套名为 AllNonGWTTestCaseTests

Here are some lines we used on a project. Here launching a suite called AllNonGWTTestCaseTests

<target name="runTests" description="Run JUnit tests">
    <junit printsummary="yes" dir="test-classes" fork="true">
        <classpath>
            <pathelement location="inst-classes" />
        </classpath>
        <test name="xxx.AllNonGWTTestCaseTests" haltonfailure="no" outfile="result">
            <formatter type="xml" />
        </test>
    </junit>
</target>

建筑,这将创建该文件为result.xml。这种配置的Ant任务。
詹金斯可以启动这个Ant任务。看看你的项目配置。第构建和GT; Ant任务。然后在生成后操作刚才设置的路径XML文件:为result.xml

Building this will create the file result.xml. That configures an ant task. Jenkins can launch this ant task. Take a look at your project configuration. Section Build > Ant task. Then in Post-build Actions just set the path to the xml file : result.xml

这应该使詹金斯运行测试套件作为后生成操作。

This should make Jenkins run the test suite as a post build action.

这篇关于如何设置詹金斯使用JUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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