0

有一部分带有junit任务的ant脚本:

...

<target name="test">
  <mkdir dir="path_to_report_dir">
  <junit fork="true" printsummary="true" showoutput="true" maxmemory="1024M">
    <classpath ... />
    <batchtest todir="path_to_report_dir">
        <formatter type="xml" />
        <fileset ... />
    </batchtest>
  </junit>
</target>

...

该脚本适用于 Eclipse 和命令行。但它在 TeamCity 中不起作用。TeamCity 中的最后一条信息性消息是:[mkdir] Created dir: path_to_report_dir Process exit code: 0

看起来 junit 任务不起作用,并且它停止执行所有脚本。麻烦在哪里?

4

2 回答 2

1

The cause was in <fileset> file list. The TeamCity version of Ant doesn't work with strings like "/test/" (this mean select all files recursively); it only works with strings like "**/test/*.class". The local version of Ant supports both variants.

Thanks.

于 2012-05-30T09:33:19.827 回答
0

不知道这是否有帮助....但这是我的标准测试目标:

<target name="test" depends="compile-tests">
    <junit printsummary="yes" haltonfailure="yes">
        <classpath>
            <path refid="test.path"/>
            <pathelement path="${classes.dir}"/>
            <pathelement path="${test.classes.dir}"/>
        </classpath>
        <formatter type="xml"/>
        <batchtest fork="yes" todir="${test.reports.dir}">
            <fileset dir="${test.src.dir}">
                <include name="**/*Test*.java"/>
                <exclude name="**/AllTests.java"/>
            </fileset>
        </batchtest>
    </junit>
</target>

构建输出:

test:
    [junit] Running org.demo.AppTest
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.056 sec

笔记

  • 使用 Junit 4.10。
于 2012-05-29T18:39:59.950 回答