22.11.11

Junit Failures : no more eye-grepping --- !

Hi guys : Have you ever had to grep a list of 200 unit tests for the Failures ? Or maybe, your smart enough to save yourself the trouble.... So you have the unit test fail immediately after a failure. Any failure. And then - your source gets unstable, and you KNOW that tests are failing... but you want to know HOW MANY. And you can't --- because your builds STOP after the first test.

All because you didn't know how to do this . In ant on *nix , you can easily just grep for the failures in your test reports directory. This is because the Junitreport task will WRITE OUT ALL RESULTS TO XML FILES for you.

This quick little grep might save you alot of time if you want to know, without eye-grepping, how many tests failed.

<em><!-- Capture all failures, simple debugging statements. -->
<junitreport>
<fileset dir="${reports.dir}/tmp">
<include name="*.xml" />
</fileset>
<report todir="${reports.dir}/final" />
</junitreport>

<echo message="... Scanning for any failed MY_APP_NAME junit tests... "/>
<exec executable="grep">
<arg value="-r" />
<arg value="-m" />
<arg value="1" />
<arg value="-rl" />
<arg value="errors=\&quot;[1-9]\&quot;" />
<arg value="${reports.dir}" />
</exec>
<echo message="...DONE Grepping for failures/errors outputs : "/>
<fail if="junit.failed" message="FAILING - unit tests failed." /></em>










































































No comments:

Post a Comment