2016-09-14 68 views
0

我想我的蚂蚁junit目标接受来自用户的字符串值。这个String值基本上就是包名.JUnit目标应该在这个包下运行测试,而不是任何其他测试。我如何做同样的事情。目前,我的junit目标如下所示:蚂蚁junit目标运行具有某种模式的测试?

<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> 

如何修改此操作以仅根据给定输入运行测试?

回答

0

fileset资源,与封装的标准添加include图案,例如:

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

更多的例子参见documentation