运行 单元测试需要 maven surefire 插件吗?

Is the maven surefire plugin needed to run unit tests?

使用mvn clean test命令时运行单元测试是否需要maven surefire插件?

我阅读了文档并知道它说的是:

The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in two different file formats:

Plain text files (.txt) XML files (.xml) By default, these files are generated at ${basedir}/target/surefire-reports.

但是,我 运行 测试没有使用 surefire 插件,它们都通过了。

不,不需要,但 maven 默认使用。如果你有更好的插件,你可以改变它。但我更喜欢默认值。

maven-surfire-plugin 绑定到默认生命周期的测试阶段。 maven-surfire-plugins 运行所有匹配文件名模式 Test*.java、*Test.java 和 *TestCase.java 的测试位于目录 src/test/java.

有关详细信息,请查看 http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

您可以在控制台输出上验证这一点...这是 mvn test 的尾部输出...:[=​​13=]

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ rechnungsverwaltung ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rechnungsverwaltung ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.447 s
[INFO] Finished at: 2015-10-17T22:36:59+02:00
[INFO] Final Memory: 18M/304M
[INFO] ------------------------------------------------------------------------

看看这行。在那里你可以看到使用了 maven-surefire-plugin

[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @