You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Keith Hatton <kh...@axiomsystems.com> on 2005/03/01 10:02:15 UTC

RE: if junit batchtest is skipped also skip junitreport?

Praise indeed! Thanks Dominique. I should add that I got the
<pathconvert ... setonempty="false"> tip from this list, somewhere.

I wonder if I have encountered something similar to the scenario you
describe. Every now and then (when something either in my code or my
test environment is completely broken) the Junit task can generate a
0-byte XML file, which causes JUnitReport to barf. I haven't been too
concerned about this, as it's mainly a sign that something of mine is
wrong, but it is a bit unclean and might cause an unattented build to
hang. Hasn't happened recently, maybe was an issue with 1.6.1 but I
upgraded to 1.6.2 a few weeks ago, or maybe my code is better now :).

Keith


-----Original Message-----
From: Dominique Devienne [mailto:DDevienne@lgc.com] 
Sent: 28 February 2005 17:28
To: Ant Users List
Subject: RE: if junit batchtest is skipped also skip junitreport?


This is an elegant solution IMHO.

It has one little flaw, which really isn't; a test that crashes the VM
(can happen with native code and JNI) prevents the XML file from being
generated. So using forkmode="perTest", you'd be missing one or more of
these XML files, and if all tests were of this category, you could in
theory have run some tests, all of them failing. But what's the point of
running the report when you have no input ;-) Which is why I say it's
not really a flaw.

The fact that <junit> missed such 'crashing' failures may have been
fixed I think, as I vaguely recall a bug about this. --DD

> -----Original Message-----
> From: Keith Hatton [mailto:khatton@axiomsystems.com]
> Sent: Monday, February 28, 2005 11:17 AM
> To: Ant Users List
> Subject: RE: if junit batchtest is skipped also skip junitreport?
> 
> I recently did this but was unable to do it with a purely
macrodef-based
> approach.
> The gist of my solution was to define the fileset generated by Junit.
> 
>     <fileset id="junit.raw" dir="${blah}" includes="TEST-*.xml"/>
> 
> Then check if it was actually there:
> 
>     <target name="junitcheck">
>         <!-- did we actually run any unit tests? -->
>         <pathconvert targetos="windows" refid="junit.raw"
>             property="report.junit" setonempty="false"/>
>     </target>
> 
> Then only do the junitreport if the property was set:
> 
>     <target name="junitreports" depends="junitcheck"
if="report.junit">
>         <junitreport>
>             <fileset refid="junit.raw"/>
>             <report format="frames" todir="${report}"/>
>         </junitreport>
>     </target>
> 
> Hope thie helps, and if anyone has more elegant solutions I'd be 
> delighted to hear them!
> 
> Keith
> 
> 
> 
> -----Original Message-----
> From: Jon Jagger [mailto:jon@jaggersoft.com]
> Sent: 28 February 2005 15:03
> To: user@ant.apache.org
> Subject: if junit batchtest is skipped also skip junitreport?
> 
> 
> I have a package based ant setup which uses the following...
> 
> <macrodef name="run-test"
>     <attribute name="package"//>
>     ...
>     <sequential>
>         ...
>        <junit errorProperty="test.failed" ...>
>           ...
>           <formatter type="xml"/>
>           <batchtest todir="..."
>                          unless="@{package}.tests.uptodate">
>              ...
>           <batchtest>
>         </junit>
>         ...
>         <fail if="test.failed"/>
>         ...
>         <junitreport todir="....>
>           ...
>         </junitreport>
>   </sequential>
> </macrodef>
> 
> This works but I'd like to run the junitreport only if batchtest 
> actually runs some tests. In other words, I like an unless on 
> junitreport to mirror the unless on batchtest. But there isn't one and
I
> 
> can't see an obvious answer in chapter 4 of Erik & Steve's excellent
ant
> 
> book. Is there a way to do this without resorting to the <if> 
> ant-contrib?
> 
> 
> Also, I'm using a flag file to indicate whether a test-run passed or 
> failed. That way I can rerun the tests even if none of the code being 
> tested or the code doing the tests has changed. Exactly as Erik and 
> Steve suggest in chapter 4 (pages 106-108). Is there a way to stop the

> <delete> task from echoing a successful deletion message to the
console?
> 
> Many thanks
> Jon
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: if junit batchtest is skipped also skip junitreport?

Posted by Jon Jagger <jo...@jaggersoft.com>.
Thanks to those whose suggested approaches. I have thought about it and 
decided that the most elegant solution is to unask the question. Viz I 
have decided not to run junitreport after each junit. Instead I'll have 
a separate task that reports on all existing TEST-*.xml files. I was 
using the index.html file from junitreport in an uptodate condition; 
instead I'm now simply creating a file if and when junit passes.
Thanks
Jon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org