如何通过Ant显示jUnit错误

Sno*_*irl 3 ant junit

我正在尝试将Ant脚本添加到我公司的项目中以运行jUnit测试.这是我有的:

<target name="unit-tests">
    <junit>
        <classpath>
            <pathelement location="${project.libext.dir}/junit-4.1.jar"/>
        </classpath>
        <batchtest>
            <fileset dir="${project.src-test.dir}/my/company/." />
        </batchtest>
    </junit>
</target>
Run Code Online (Sandbox Code Playgroud)

该脚本正确地抓取我的jUnit测试,但它说有错误.但所有输出都会说:

[junit] Test package.MyTest FAILED
Run Code Online (Sandbox Code Playgroud)

我想知道它失败的原因.我曾尝试加入一些属性到的junit标记(printsummary,showoutput,等),但似乎无法找到合适的组合.我设法得到的最好的是:

[junit] Running package.MyTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
Run Code Online (Sandbox Code Playgroud)

我真的需要完整的堆栈跟踪等,因为当我通过Eclipse运行为> Junit测试时,测试运行正常.

任何人都知道如何打印堆栈跟踪?

Sno*_*irl 7

找到了答案.需要添加格式化程序.

<target name="unit-tests">
    <junit>
        <classpath>
            <pathelement location="${project.libext.dir}/junit-4.1.jar"/>
        </classpath>
        <formatter type="plain" usefile="false" />
        <batchtest>
            <fileset dir="${project.src-test.dir}/my/company/." />
        </batchtest>
    </junit>
</target>
Run Code Online (Sandbox Code Playgroud)