Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
523 views
in Technique[技术] by (71.8m points)

ant - Jenkins JUnit Test Result Report plugin states that the JUnit xml file is not found?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...