Do you need the maven surefire plugin to run unit tests?

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

I have read the documentation and know that it says that:

The Surefire plugin is used during the assembly testing phase of the life cycle to run unit tests of the application. It generates reports in two different formats:

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

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

+6
source share
1 answer

no is required , but maven is used by default by default. if you have a better plugin, you can change it. but I would prefer the default.

maven-surfire-plugin is tied to the default life cycle test phase. maven-surfire plugins run all tests that match the pattern file name Test * .java, * Test.java und * TestCase.java are in the src / test / java directory.

for more information see http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

you can check this at the console output ... here is the tail 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] ------------------------------------------------------------------------ 

Look at the line. there you can see what maven-surefire-plugin is used

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

All Articles