Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 805
Kingamere Avatar asked Oct 17 '15 20:10

Kingamere


1 Answers

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) @ 
like image 89
StefanHeimberg Avatar answered Oct 29 '22 13:10

StefanHeimberg