Run all unit tests with Ant builder

吃可爱长大的小学妹 提交于 2019-11-30 22:18:30

Yep it is, you need to look at the fileset tag, e.g:

<junit printsummary="yes" haltonfailure="yes">
  <classpath>
    <pathelement location="${build.tests}"/>
    <pathelement path="${MyProject.classpath}"/>
  </classpath>

  <formatter type="xml"/>

  <batchtest fork="yes" todir="${reports.tests}">
    <fileset dir="${src.tests}">
      <include name="**/*Test*.java"/>
      <exclude name="**/AllTests.java"/>
    </fileset>
  </batchtest>
</junit>

The important part is the use of fileset and a glob/wildcard pattern to match the names of the tests. Full docs on the junit task with examples here:

http://ant.apache.org/manual/Tasks/junit.html

Yep! We do it using an ant command batchtest. Looks like this:

        <batchtest todir="${junit.report.dir}">
            <fileset dir="${basedir}\test\unit">
                <include name="**/*Test.java" />
            </fileset>
        </batchtest>

Google it, it should sort you out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!