ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: how to run single test method inside TestCase using Ant
Date Wed, 10 Dec 2003 11:14:02 GMT
I tried that on Ants codebase and it worked. 

Jan



<project default="testMethod">

    <import file="build.xml"/>

    <target name="testMethod">
        <!-- name for the temporary test suite -->
        <property name="suite" value="TmpSuite"/>

        <!-- what is to test -->
        <property name="test.class"
value="org.apache.tools.ant.taskdefs.EchoTest"/>
        <property name="test.method" value="test2"/>

        <!-- create a new java class -->
        <echo file="${tests.dir}/${suite}.java">
import junit.framework.*;

public class ${suite} {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(new ${test.class}("${test.method}"));
    return suite;
  }
}
        </echo>

        <!-- compile the suite -->
        <!-- done via depends clause of 'run-single-test' -->
        <!-- <antcall target="compile-tests"/> -->

        <!-- do the test -->
        <antcall target="run-single-test">
            <param name="testcase" value="${suite}"/>
        </antcall>

        <!-- delete temp files -->
        <delete file="${tests.dir}/${suite}.java"/>
        <delete file="${build.tests}/${suite}.class"/>
    </target>

</project>


> -----Original Message-----
> From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> Sent: Wednesday, December 10, 2003 8:49 AM
> To: user@ant.apache.org
> Subject: RE: how to run single test method inside TestCase using Ant
> 
> 
> Not directly, <junit> is a usual test runner. And the test runner uses
> the suite() method of the test case. So you have to provide 
> such a method.
> 
> But if you know the class and method name you can generate a 
> new class for
> this purpose (<echo> or <copy><filterchain>) ...
> 
> 
> Jan
> 
> 
> > -----Original Message-----
> > From: Dickson, Craig [mailto:craig_dickson@xelus.com]
> > Sent: Wednesday, December 10, 2003 2:49 AM
> > To: JUnit List (E-mail); Ant List (E-mail)
> > Subject: how to run single test method inside TestCase using Ant
> > 
> > 
> > Is it possible, using the junit task from Ant (1.6), to run a 
> > single test
> > method inside a TestCase class?
> > 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message