问题描述
|
我必须为Junit报告编写一个蚂蚁目标。它是一个现有的应用程序。一些测试类文件被命名为TestSample.java或SampleTest.java。但是有些HeaderTest.java编写的Java文件与junit测试用例没有任何关系,它没有扩展TestCase。
如何过滤这些calss文件?
<junit printsummary=\"on\" fork=\"off\" haltonfailure=\"false\" showoutput=\"true\">
<classpath>
<path refid=\"CLAsspATH_JUNIT\"/>
</classpath>
<batchtest fork=\"off\" todir=\"${BUILD_TEST_DIR}\">
<fileset dir=\"${TEST_CLASSES_DIR}\">
<include name=\"**/*Test.class\" />
<include name=\"**/Test*.class\" />
</fileset>
</batchtest>
<formatter type=\"xml\" />
</junit>
解决方法
fileset
也有exclude
。
<exclude name=\"**/DoNotIncludeThisOne.class\" />
,用ѭ4显式排除它们,或者甚至更好地重构它们,以便它们遵守命名约定:* Test类应该是测试用例。
参见http://ant.apache.org/manual/Types/fileset.html