ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: junit batchtest using a single testsuite
Date Wed, 11 Feb 2004 00:41:13 GMT
> From: Joel Hockey [mailto:joelhockey@hotmail.com]
> 
> I have come up with a solution for my problem.  I have created a
> DynamicTestSuite that creates a test suite by matching all classes in a
> given classpath against a given suffix.  (This could easily be changed to
> use a regular expression).

Yeap, that's pretty much the gist of it.

>     <junit printSummary="true" fork="yes" haltonfailure="yes">
>       <classpath>
>         <path location="build/classes"/>
>         <path location="build/test-classes"/>
>         <path refid="classpath"/>
>       </classpath>
>       <formatter type="xml"/>
>       <formatter type="plain" usefile="false"/>
>       <sysproperty key="test.classes.dir"
> value="${basedir}/build/test-classes"/>
>       <sysproperty key="test.suffix" value="${test.pattern}Test.class"/>
>       <test name="cash.DynamicTestSuite" todir="build/report"/>
>     </junit>

I of course used the same technique to configure the dynamic test suite thru
system properties. I wrote <propertyset> (<syspropertyset> when in <junit>)
which Stefan incorporated to Ant 1.6 precisely to pass in all these
configuration properties in one go, using:

      <syspropertyset>
        <propertyref prefix="testall." />
        <mapper type="regexp" from="testall\.(.*)" to="\1" />
      </syspropertyset>

If you use more than one config property, that's handy.

On the news front though, I think I've found a better way that will let Ant
do all the scanning of dirs and selection of files using the very powerful
Ant mechanism (patternset + selectors), while still using a variant of
DynamicTestSuite. When I get around to it, I'll post it, but it could take a
few weeks to get to it. Will subclass JUnitTask, but not require changes in
Ant, as usual from me.

Note that DynamicTestSuite-like technique kinda break <junitreport>, who
think a single test case with a bunch of test methods was run, instead of a
composition of other test cases... That's unfortunate, since Test
composition is one of the tenets of JUnit.

You can also checkout a patch submitted in bugzilla against Ant 1.5 that
adds a fork="once" to <junit>, but that's intrusive to Ant. --DD

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


Mime
View raw message