为ant junit batchtest指定文件名

为ant junit batchtest指定文件名,ant,junit,Ant,Junit,我有一个工作的ant任务,它以以下方式运行一批junit测试: <junit printsummary="yes" showoutput="yes" haltonfailure="no"> <formatter type="plain" /> <classpath> <path refid="app.compile.classpath" /> <path id="classes" locatio

我有一个工作的ant任务,它以以下方式运行一批junit测试:

<junit printsummary="yes" showoutput="yes" haltonfailure="no">
    <formatter type="plain" />
    <classpath>
        <path refid="app.compile.classpath" />
        <path id="classes" location="${app.classes.home}" />
        <path id="test-classes" location="${app.build.home}/test-classes" />
    </classpath>
    <batchtest fork="no" todir="${app.tests.reports}">
        <fileset dir="${app.tests.home}">
            <include name="**/*Test*.java" />
        </fileset>
    </batchtest>
</junit>
是否有办法为batchtest的报告文件指定文件命名模式,最好是为ant 1.6.5指定文件命名模式?

我知道,对于单个测试,可以使用
outfile
属性指定文件名。在报告中,刚刚声明:

然后,它为每个以
.java
.class
结尾的资源生成一个测试类名

不,不可能

根据源代码

protected void execute(JUnitTest arg, int thread) throws BuildException {
    validateTestName(arg.getName());

    JUnitTest test = (JUnitTest) arg.clone();
    test.setThread(thread);

    // set the default values if not specified
    //@todo should be moved to the test class instead.
    if (test.getTodir() == null) {
        test.setTodir(getProject().resolveFile("."));
    }

    if (test.getOutfile() == null) {
        test.setOutfile("TEST-" + test.getName());
    }

    // execute the test and get the return code
    TestResultHolder result = null;
    if (!test.getFork()) {
        result = executeInVM(test);
    } else {
        ExecuteWatchdog watchdog = createWatchdog();
        result = executeAsForked(test, watchdog, null);
        // null watchdog means no timeout, you'd better not check with null
    }
    actOnTestResult(result, test, "Test " + test.getName());
}
如果您没有在
TEST
元素中明确指定它,它将创建输出文件为
“TEST-”+TEST.getName()
。无法在
batchtest
元素中指定它

protected void execute(JUnitTest arg, int thread) throws BuildException {
    validateTestName(arg.getName());

    JUnitTest test = (JUnitTest) arg.clone();
    test.setThread(thread);

    // set the default values if not specified
    //@todo should be moved to the test class instead.
    if (test.getTodir() == null) {
        test.setTodir(getProject().resolveFile("."));
    }

    if (test.getOutfile() == null) {
        test.setOutfile("TEST-" + test.getName());
    }

    // execute the test and get the return code
    TestResultHolder result = null;
    if (!test.getFork()) {
        result = executeInVM(test);
    } else {
        ExecuteWatchdog watchdog = createWatchdog();
        result = executeAsForked(test, watchdog, null);
        // null watchdog means no timeout, you'd better not check with null
    }
    actOnTestResult(result, test, "Test " + test.getName());
}