Displaying custom test results in Jenkins Maven job

continuous-integration, jenkins, maven

Solution

I worked through this problem by using a "free-style software project" in Jenkins rather than the "maven2/3" project.

Under Build, choose Add build step and configure the project to Invoke top-level Maven targets. I'm using the test target.

Finally, under Post-build Actions choose Add post-build action of Publish JUnit test result report and point it at the xUnit output from your tests. This option is not available for Maven 2/3 jobs for some reason.

Problem

I just added some Python unit tests to an existing Maven POM but I can't seem to get Jenkins to report the results of the tests when it runs the build. I'm running nose tests from Maven with the exec-maven-plugin during the "test" phase. The tests run successfully from the Jenkins job and generate an xUnit compatible test report to target/surefire-reports/TEST-nosetests.xml, but Jenkins doesn't pick up on the results. Interestingly, Maven also reports no tests run before executing the test suite: ``` ------------------------------------------------------- T E S T S ------------------------------------------------------- There are no tests to run. Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- exec-maven-plugin:1.1.1:exec (nosetests) @ server --- [INFO] ................ [INFO] ---------------------------------------------------------------------- [INFO] Ran 16 tests in 194.799s [INFO] [INFO] OK [INFO] Registering compile source root /Volumes/Data/workspace/myProject/target [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ ``` So is this a problem with Jenkins not seeing the results, or with Maven not treating my test suite as actual tests?

Original source