0

First, I have searched in stackoverflow, the following questions are related to mine, but not exactly what I wanted:

Suppose I have more than 100 test cases: A1Test... A100Test. I can make bachtest of junit in ant to run all of them. But I only want to run, say, A50Test. How I config my build.xml, so that I can run:

ant test A50Test

I don't want to create 100 targets for each of the test.

sean
  • 1,632
  • 2
  • 15
  • 34

2 Answers2

2

Introduce property which defines test name you want to execute:

<property name="unit.test" value="*.java" />

Use this property in your batchtest:

<batchtest fork="yes" todir="${output.test.dir}">
    <fileset dir="${source.test.dir}" includes="**/${unit.test}"/>
</batchtest>

Pass value for this property to ant:

ant test -Dunit.test=A50Test
hoaz
  • 9,883
  • 4
  • 42
  • 53
0

but in my case, I need to add ".java" at the end of ${unit.test} make it worked.
hope to help someone. ^^

<batchtest fork="yes" todir="${output.test.dir}">
    <fileset dir="${source.test.dir}" includes="**/${unit.test}.java"/>
</batchtest>
eliam
  • 1