How to setup Jenkins with JUnit

独自空忆成欢 提交于 2019-11-29 11:59:59
Michael Laffargue

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

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>

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.

Simple solution (step by step) is here !

1)Add xUnit Plugin to Jenkins

2)Add these below sample code Execute Windows Batch Command under build section (Command) of Jenkins.

javac xyxTest.java //compile your test class 
java xyzTest // run your test class

3) Add "Publish Junit test result report"

Here is the link ,where you will find details of it.

http://www.tutorialspoint.com/jenkins/jenkins_unit_testing.htm

Hope it will help!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!