jenkins the definitive guide

(Jeff_L) #1

6.3. Configuring Test Reports in Jenkins


Once your build generates test results, you need to configure your Jenkins build job to display them.
As mentioned above, Jenkins will work fine with any xUnit-compatible test reports, no matter what
language they are written in.


For Maven build jobs, no special configuration is required—just make sure you invoke a goal that will
run your tests, such as mvn test (for your unit tests) or mvn verify (for unit and integration tests).
An example of a Maven build job configuration is shown in Figure 6.1, “You configure your Jenkins
installation in the Manage Jenkins screen”.


Figure 6.1. You configure your Jenkins installation in the Manage Jenkins screen


For freestyle build jobs, you need to do a little more configuration work. In addition to ensuring that
your build actually runs the tests, you need to tell Jenkins to publish the JUnit test report. You configure
this in the “Post-build Actions” section (see Figure 6.2, “Configuring Maven test reports in a freestyle
project”). Here, you provide a path to the JUnit or TestNG XML reports. Their exact location will
depend on a project—for a Maven project, a path like */target/surefire-reports/.xml will
find them for most projects. For an Ant-based project, it will depend on how you configured the Ant
JUnit task, as we discussed above.

Free download pdf