我試着寫與JUnit測試的螞蟻,卻得到如下結果:螞蟻junit任務不報告詳細
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 也試圖從ant -v or ant -debug
開始,但沒有得到任何好運。誰能幫忙?
<junit printsummary="yes" showoutput="true">
螞蟻1.8.2,太陽jdk1.6.0_20,JUnit的4.8.2
縮小的問題,我創建了一個單獨的項目 這是我的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
package com.mytest.unittest;
import junit.framework.TestCase;
public class SimpleTest extends TestCase{
public void testFirst()
{
assertTrue(true);
}
}
C:\ TestPrj>蟻
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
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結果/細節/報告產生的? 因此,在我真實的失敗案例中,我無法解決我的問題?
這可以工作,但是一旦所有測試運行完畢,它就會將結果輸出到屏幕上。我希望看到它們隨時可以運行,以便我可以監控進度。任何你知道要這樣做的方式? – crowmagnumb 2014-05-29 19:50:57
請看這裏:http://stackoverflow.com/questions/18293054/immediate-junit-test-logging-with-junit-ant-task – lesmana 2014-05-29 21:30:39