0
votes

I want to my ant junit target to accept a String value from user. This String value will basically be the package name .The junit target should run the test present under this package and not any other test. How do i do the same. Currently , my junit target looks like this:

<target name="junit" if="run.junit">
        <junit dir="${project.root}" fork="true">
            <classpath> 
                <path refid="junit.classpath"/>
            </classpath>
            <batchtest >
                <fileset dir="test">
                </fileset>
            </batchtest>
        </junit>
    </target>

How do i modify this to run the tests only as per the given input?

1

1 Answers

0
votes

In the fileset resources, add an include pattern with the package criteria, e.g.:

<junit dir="${project.root}" fork="true">
     <classpath> 
         <path refid="junit.classpath"/>
     </classpath>
     <batchtest >
         <fileset dir="test">
            <include name="my/package/**"/>
         </fileset>
     </batchtest>
</junit>

See the documentation for more examples.