PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 27, 2022

[FIXED] How to setup Jenkins with JUnit

 September 27, 2022     ant, continuous-deployment, continuous-integration, jenkins, junit     No comments   

Issue

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 theJUnit 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?


Solution

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.



Answered By - Michael Laffargue
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing