我在maven下运行Junit测试 mvn clean test -Dtest = MyTest
输出如下:
[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] ------------------------------------------------------------------------
之前我做过工作,即我在测试进行时在控制台上逐行测试输出。一段时间(可能是更新)停止了。
任何想法背后的原因是什么?
答案 0 :(得分:0)
surefire插件默认将输出写入文件。这可以通过useFile
option来控制,{{3}}可以从命令行设置:
-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>