繁体   English   中英

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

[英]Is the maven surefire plugin needed to run unit tests?

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

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

Surefire插件在构建生命周期的测试阶段使用,以执行应用程序的单元测试。 它以两种不同的文件格式生成报告:

纯文本文件( .txt)XML文件( .xml)默认情况下,这些文件是在$ {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 ...的尾输出:

[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) @ 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM