7dr3am7
7dr3am7

Reputation: 765

Running Junit task in Ant

From the title I've put the question can seem very obvious... but it isn't (for me anyway)

I have 2 very simple questions. When you run a junit test and you have to specify the the name i.e.

<junit>
<test name="my.single.test"/>
</junit>

Does it match the path against the src folder(therefore java classes)?

Is there a way of running Junit from a jar? For example, I export all the test into a jar and I want to be able to run those test within the junit task. I know you can use < batchtest> and < fileset> (combined), but I think it works only for .java files, doesn't it?

Upvotes: 0

Views: 5021

Answers (2)

卢声远 Shengyuan Lu
卢声远 Shengyuan Lu

Reputation: 32014

<junit>
    <classpath> 
        <fileset dir="yourLibDir">
          <include name="**/your.jar"/><!--my.single.test in your.jar-->
        </fileset>
    </classpath>
    <test name="my.single.test"/>
</junit>

Upvotes: 3

StanislavL
StanislavL

Reputation: 57421

All you need is to specify proper classpaths. See the example http://ideoplex.com/id/25/ant-and-junit

Upvotes: 3

Related Questions