20

The exact message received from jenkins is:

No test report files were found. Configuration error?
Build step 'Publish JUnit test result report' changed build result to FAILURE

When configuring the JUnit Test Result Report plugin, on entering the 'Test Report XMLs' path as '/reports/TEST-*.xml', the following error is displayed beneath the path:

'/reports/TEST-*.xml' doesn't match anything: '' exists but not '/reports/TEST-*.xml'

I have tried using the full path as well but that produces the same result. In both cases the paths should have picked up the 'TESTS-TestSuites.xml' file that was present in the /reports directory.

I'm not sure whether this is a problem with the plugin or the XML file being generated. I'm also aware that it could be an issue with the ant build script that I have written to run the JUnit tests and produce the XML result file therefore I have included the contents of this below in case something needs to be changed:

<?xml version="1.0" encoding="utf-8"?>
<project name="jenkins-tests" basedir="." default="linux">

<property name="junit.output.dir" value="output"/>
<property name="src.dir" value="src"/>
<property name="lib.dir" value="libs" />
<property name="bin.dir" value="bin" />
<property name="full-compile" value="true" />

<path id="classpath.base"/>

<path id="classpath.test">
    <pathelement location="${bin.dir}" />
    <pathelement location="${src.dir}" />
    <pathelement location="${lib.dir}" />
    <pathelement location="${lib.dir}/junit.jar" />
    <path refid="classpath.base" />
</path>

<target name="clean" description="Clean up build artefacts">
    <delete dir="${basedir}/${junit.output.dir}" />
</target>

<target name="prepare" depends="clean" description="Prepare for build">
    <mkdir dir="${basedir}/${junit.output.dir}" />
    <mkdir dir="${junit.output.dir}/reports"/> 
</target>

<target name="compile" depends="prepare">
    <javac srcdir="${src.dir}" destdir="${bin.dir}" verbose="${full-compile}" includeAntRuntime="false" >
        <classpath refid="classpath.test"/>
    </javac>
</target>

<target name="test" depends="compile">
    <junit printsummary="true" haltonfailure="false">
        <formatter type="xml" usefile="true"/>
        <classpath refid="classpath.test" />
        <batchtest fork="yes" todir="${junit.output.dir}">
            <fileset dir="${src.dir}">
                <include name="*.java"/>
            </fileset>
        </batchtest>
    </junit>
</target>

<target name="test-reports" depends="test">
    <junitreport tofile="TESTS-TestSuites.xml" todir="${junit.output.dir}/reports">
        <fileset dir="${junit.output.dir}">
            <include name="TEST-*.xml" />
        </fileset>
        <report format="frames" todir="${junit.output.dir}/reports" />
    </junitreport>
</target>
</project>

I've been researching into this problem for a while now and haven't found any solution so I would appreciate any help. Thanks.

Ben
  • 201
  • 1
  • 2
  • 4
  • 1
    Did you run the tests at least once? This error does appear when configuring the plugin for the first time. – Jayan Feb 18 '13 at 16:40
  • Yeah, the tests run fine and say the build is successful. It's only trying to generate the reports with the plugin that cause the build to fail. – Ben Feb 18 '13 at 17:26
  • @ Ben : Could you browse to the TEST*xml files via jenkins->job->workspace->... ? It will give an idea what pattern is really needed. Shiva Kumar's answer should have worked. – Jayan Feb 19 '13 at 08:36
  • @Jayan I had a look in the job's workspace. It's strange as on my local server the path is \Clients\website\versions\ben\includes\fuel\app\tests\selenium\JenkinsTests\outp‌​ut\reports whereas in the replicated path under jenkins/job/workspace in includes/fuel/app the tests directory and those directories within it are not there. Do you know why? – Ben Feb 20 '13 at 08:47
  • @ Ben : jenkins has default workspace , managed by itself. It also allows you to provide a custom workspace (hidden under advanced setting of job) – Jayan Feb 20 '13 at 10:43
  • @ Jayan : Output I now have is... test-reports: [junitreport] Processing /var/lib/jenkins/jobs/jenkins-tests/workspace/includes/fuel/app/tests/selenium/JenkinsTests/output/reports/TESTS-TestSuites.xml to /tmp/null727956119 [junitreport] Loading stylesheet jar:file:/usr/share/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl [junitreport] Transform time: 578ms [junitreport] Deleting: /tmp/null727956119 1/2 – Ben Feb 20 '13 at 17:01
  • BUILD SUCCESSFUL Total time: 2 seconds Recording test results No test report files were found. Configuration error? Build step 'Publish JUnit test result report' changed build result to FAILURE Finished: FAILURE – Ben Feb 20 '13 at 17:02

2 Answers2

20

Jenkins looks for the path from the workspace root. Ensure that the given path is correct or use wildcards to look in multiple locations. Try using **/reports/TEST-*.xml Are you sure the reports folder is right under the workspace? Verify manually if the test result files are indeed present in the location given in the path.

Shiva Kumar
  • 3,111
  • 1
  • 26
  • 34
  • I've used that path and it has gotten rid of the initial path error but I still get the xml not found error when running the job. Maybe the reports folder is in the wrong place. Currently Jenkins runs on a separate server to the tests. Would the reports folder have to be on the Jenkins server and the reports in the ant script pointed to there? – Ben Feb 18 '13 at 11:26
  • On the local server (not the jenkins server) I have the base directory that contains the src, bin and libs directories for my JUnit tests as well as the ant build xml file. The build.xml file makes the output directory (${junit.output.dir}) alongside these other directories when it runs and then the reports directory is made within there. The jenkins directories are completely separate on their own server. I just looked on the jenkins server and I have the following path to the job's workspace: /var/lib/jenkins/jobs/jUnit Test/workspace Should the reports, test and build.xml be here instead? – Ben Feb 18 '13 at 12:09
  • \Clients\website\versions\ben\includes\fuel\app\tests\selenium\JenkinsTests\output\reports – Ben Feb 18 '13 at 12:45
  • This does not look like it is in the place where the job is run. Can you check by giving full path \Clients\website\versions\ben\includes\fuel\app\tests\selenium\JenkinsTests\outp‌​ut\reports\TEST-*.xml and check in the JUnit Report plugin? And can you tell if your src, bine and lib directories are coming from SVN or they exist in hardcoded path in the local server? – Shiva Kumar Feb 18 '13 at 13:11
  • The full path produces the same errors and the src, bin and libs directories exist are in a hardcoded path in the local server. – Ben Feb 18 '13 at 13:55
8

For my Android project which has multiple Gradle product flavors I used the following path for Test report XMLs:

**/build/test-results/**/TEST-*.xml

JUnit plugin

JJD
  • 50,076
  • 60
  • 203
  • 339
  • That path helped me out, thanks. It works, however, only with JUnit4. I keep trying over and over again with JUnit5, using different paths, without success. Do you know any other path that might work with JUnit5 also? Or any other workaround... It would be appreciated ;) – arthur0304 Apr 12 '19 at 09:24
  • 2
    @arthur0304 I haven't looked into grabbing JUnit5 test results. Therefore, I strongly suggest that you post your issue as a separate question on Stackoverflow so it gets much more attention than your comment here. – JJD Apr 13 '19 at 14:31