1
votes

I wanted to check that my Jenkins job setup works correctly, so I made a test which fails. When running that Job, the build has succeeded but some unit tests fails.

In the 'Console Output' I can see the failed tests but if I take a look at the tests results of the build, no test was marked as failed.

This is the failing Test:

<target name="RennenTest">  
    <mkdir dir="${junit.output.dir}"/>
    <junit fork="yes" printsummary="withOutAndErr">
        <formatter type="xml"/>
        <test name="RennenTest" todir="${junit.output.dir}"/>
        <classpath refid="Rennschnecke_Example.classpath"/>
    </junit>
</target>

What do I have to do that the Tests Results shows me the Failed tests and that Jenkins doesn't marks the build as success?

Jenkins configuration:

Source Code Management:

Git

Repositories Repository URL https://github.com/kevinswen/testSchnecke.git

Branches to build Branch Specifier (blank for 'any') */master

Build:

Build File /home/kevin/workspace/Rennschnecke_Example/build.xml

Post-build actions:

Publish JUnit test result report

Test report XMLs **/junit/TESTS-TestSuites.xml

Health report amplification factor 1

1

1 Answers

1
votes

The following xml snippet can help you to log the failed testcase and mark the build as failure when it actually does:

<junit fork="yes" printsummary="withOutAdErr" errorProperty="test.failed" failureProperty="test.failed" logfailedtests="yes">
 .
 .
 .
</junit>
<fail message="Tests failed. Please see test reports" if="test.failed" />