蚂蚁junit任务不报告细节 [英] ant junit task does not report detail

查看:137
本文介绍了蚂蚁junit任务不报告细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写与JUnit测试蚂蚁,但得到的结果如下,

I tried to write an ant with junit test, but get below result,

unittest:
    [junit] Running com.mytest.utiltest
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    [junit] Test com.mytest.utiltest FAILED

它只是显示错误,而不打印细节,我在下面说明参数的build.xml
也试图开始与蚂蚁-v或蚂蚁-debug ,但没有得到任何运气。谁能帮助?

it just shows error without print details, i specify below parameter in build.xml also tried to start with ant -v or ant -debug, but did not get any luck. Can anyone help?

<junit printsummary="yes" showoutput="true">

蚂蚁1.8.2,太阳jdk1.6.0_20,JUnit的4.8.2

ant 1.8.2, sun jdk1.6.0_20, junit 4.8.2

要缩小问题,我创建了一个单独的项目
这是我的build.xml

to narrow down the problem, i created a seperate project this is my build.xml

<project name = "TestPrj" default="unittest" basedir = ".">

<target name="unittest" >
    <junit printsummary="yes" showoutput="true" >
        <classpath>
            <pathelement location="./junit-4.8.2.jar"/>
            <pathelement location="./ant-junit4.jar"/>
        </classpath>
        <test name = "com.mytest.unittest.SimpleTest" todir="."/>
    </junit>
</target>




</project>

下面

是simpletest.java

below is simpletest.java

package com.mytest.unittest;

import junit.framework.TestCase;


public class SimpleTest extends TestCase{
    public void testFirst()
    {
        assertTrue(true);
    }

}

C:\\ TestPrj>蚂蚁

C:\TestPrj>ant

Buildfile: C:\TestPrj\build.xml

unittest:
    [junit] Running com.mytest.unittest.SimpleTest
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0 sec

BUILD SUCCESSFUL
Total time: 0 seconds

C:\\ TestPrj> DIR

C:\TestPrj>dir

 Directory of C:\TestPrj

04/02/2011  02:00 PM    <DIR>          .
04/02/2011  02:00 PM    <DIR>          ..
04/02/2011  01:56 PM               280 .classpath
04/02/2011  01:54 PM               519 .project
04/02/2011  02:00 PM             7,120 ant-junit4.jar
04/02/2011  02:00 PM               403 build.xml
04/02/2011  01:55 PM    <DIR>          com
11/17/2010  05:36 PM           237,344 junit-4.8.2.jar
               5 File(s)        245,666 bytes
               3 Dir(s)  28,451,311,616 bytes free

我的真正的问题是,为什么有不会生成JUnit的结果/详细信息/报告?
所以,在我真正失败的情况下,我不能排除我的问题?

my real question is, why there's not a junit results/detail/report generated? so that in my real case of failure, i can not troubleshoot my questions?

THX非常

推荐答案

您必须使用格式 JUnit的内部元素任务。格式化将创建默认的报告文件,但可以迫使它在屏幕上打印结果。您可以使用两个格式化:一个是输出到屏幕,另一个用于输出到文件

You have to use a formatter element inside the junit task. The formatter will create a report file by default, but you can force it to print the results on screen. You can use two formatters: one for output to screen, another for output to file.

请注意,您不再需要在属性 printsummary =YES showoutput =真正的 junit任务。格式化正在输出的照顾了。

Note that you no longer need the attributes printsummary="yes" and showoutput="true" in the junit task. The formatter is taking care of output now.

<project name = "TestPrj" default="unittest" basedir = ".">

<target name="unittest" >
    <junit>
        <classpath>
            <pathelement location="./junit-4.8.2.jar"/>
            <pathelement location="./ant-junit4.jar"/>
        </classpath>
        <formatter type="plain" usefile="false" /> <!-- to screen -->
        <formatter type="plain" /> <!-- to file -->
        <test name = "com.mytest.unittest.SimpleTest" todir="."/>
    </junit>
</target>

</project>

阅读Ant手册中的JUnit 页面以获取更多信息。

这篇关于蚂蚁junit任务不报告细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆