0

我有一个使用 mvn clean test -Dtest=MyTest 在 maven 下运行的 Junit 测试

输出如下所示:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building autotest-tests
[INFO]    task-segment: [clean, test]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory workspace/tests/target
[INFO] [compiler:testCompile {execution: compile tests}]
[INFO] Compiling 76 source files to workspace/tests/target/test-classes
[INFO] [surefire:test {execution: run tests}]
[INFO] Surefire report directory: workspace/tests/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Concurrency config is parallel='classes', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Output of @Before block...
Output of @Before block...
Output of @Before block...

然后输出停止。从@Test 块到命令行的任何逐行输出都会被阻止,我仅在测试结束后才能在控制台上看到它们:

Output of @Test block...
Output of @Test block...
Output of @Test block...

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 75.564 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 18 seconds
[INFO] Finished at: Mon Feb 06 12:22:22 CET 2012
[INFO] Final Memory: 24M/302M
[INFO] ------------------------------------------------------------------------

我以前做过工作,即随着测试的进行,我在控制台上得到了逐行的测试输出。由于一段时间(也许是更新)停止了。

任何想法背后的原因是什么?

4

1 回答 1

0

默认情况下,surefire 插件将输出写入文件。这可以通过useFile选项来控制,可以从命令行设置:

-Dsurefire.useFile=false

也可以settings.xml通过创建和激活配置文件将其设置为您的默认值:

<profiles>
    <profile>
        <id>sureFire.useFile</id>
        <properties>
            <surefire.useFile>false</surefire.useFile>
        </properties>
    </profile>
</profile>
<activeProfiles>
    <activeProfile>sureFire.useFile</activeProfile>
</activeProfiles>
于 2012-02-06T14:10:28.967 回答