简体   繁体   中英

Is the maven surefire plugin needed to run unit tests?

Is the maven surefire plugin needed to run unit tests when using the mvn clean test command?

I read the documentation and know it says that:

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.

However, I ran the tests without using the surefire plugin and they all passed.

no not needed but it is used by maven per default. if you have a better plugin you can change it. but i would prefer the defaults.

the maven-surfire-plugin is bound to the test phase of the default lifecycle. the maven-surfire-plugins runs all Tests matches the filename pattern Test*.java, *Test.java und *TestCase.java reside in the directory src/test/java .

for more information have a look at http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

you can verify this on the console output... here is the tailed output of 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] ------------------------------------------------------------------------

Hava a look at the line. there you can see that the maven-surefire-plugin is used

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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