Reputation: 813
I would like to count the failed tests, and make a failure only once when all tests completed. These tests are run by Jenkins every night, and reporting the results if there are failures or errors. The problem is that I can't even start counting, because this has only failureProperty and errorProperty which can be true or false, but when it reaches the first failed or errorous test, it stops and fails. I didn't find good solution with google, they recommended me these properties, but they don't do what I need.
here is the code:
<junit printsummary="true" fork="yes" forkmode="once"
showoutput="false" haltonfailure="no" maxmemory="1024m"
errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="junit.classpath" />
<batchtest fork="yes" todir="${junit.dir}/raw" >
<formatter type="xml" />
<fileset dir="${classes.dir}">
<include name="**/*Test.class" />
<exclude name="*ear*/**"/>
<exclude name="**/Base*.class" />
<exclude name="**/JNDI*.class" />
</fileset>
</batchtest>
</junit>
<fail message="At least one test failed or has errors, please check test results in Jenkins to see details!" if="test.failed" />
Do I miss something important? It seems haltonfailure="no" parameter is not working in this case.
Thanks in advance if you can help me!
Upvotes: 1
Views: 2663
Reputation: 3161
Also check this answer from another similar question on how to configure your junit target both for execution and report generation. Once you generate the report, configure with the JUnit test report generation post build action.
Also have you tried using printsummary="withOutAndErr" and checked? This works completely fine for me.
Upvotes: 1
Reputation: 107040
Set the JUnit properties haltonerror
and haltonfailure
to false. Then use various reporting tools to parse the generated report. The report can be in XML format, and you can use JUnitreport to parse the file. I prefer Jenkins which will show me each build, and the number of failed JUnit tests, and all sorts of nice reports. Others use various XSLT programs (which is really what JUnitreport is).
Word 'o Caution: If you use JUnitReport, you might need a few extra jars in your Ant's lib directory. I haven't used JUnitReport in a while, but I remember I needed Xalan, but that is something that now comes with Java.
Upvotes: 1
Reputation: 15675
You need to generate a report using ant's junitreport
. This outputs an xml file that jenkins will nicely count and display for you, together with evolution graphs and so on if you are interested.
Upvotes: 1