What does the "default test" mean in the maven-surefire plugin

I defined the following configuration in my pom for confidence with TestNg:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> <configuration> <skipTests>${skip-all-tests}</skipTests> </configuration> <executions> <execution> <id>unit-tests</id> <phase>test</phase> <goals> <goal>test</goal> </goals> <configuration> <skip>${skip-unit-tests}</skip> <groups>unit</groups> <excludedGroups>integration</excludedGroups> </configuration> </execution> <execution> <id>integration-tests</id> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <skip>${skip-integration-tests}</skip> <groups>integration</groups> <excludedGroups>unit</excludedGroups> </configuration> </execution> </executions> </plugin> 

But it seems that two executions are always preceded by a “default” run, which seems to trigger every annotated @test method (at least I think so).

 --- maven-surefire-plugin:2.12:test (default-test) @ my-project 

For example, when you run "mvn test" in a project, two test executions are performed. "Default test" and "unit-test".

Can someone explain this a bit more to me? Can this be disabled or monitored (what is checked and what is not configured)?

+8
testng maven-3 maven-surefire-plugin
Aug 13 '12 at 13:25
source share
2 answers

People wanted a way to override the standard built-in plugins plugins in Maven.

Maven 3 (or it may have been introduced as early as 2.1.0 or 2.2.0), solved this by specifying a default execution identifier for each plugin execution added to the effective pom throughout the packaging life cycle.

The name of this implicit id is always default-_____ I cannot remember the exact rule for which it was created.

Thus, you can override the executions performed in the package by defining the corresponding execution.

To solve your case, I would either change <id>unit-tests</id> to <id>default-test</id> , or add

  <execution> <id>default-test</id> <configuration> <skip>true</skip> </configuration> </execution> 

or it will have the same effect, although a solution from <id>unit-tests</id> to <id>default-test</id> will be slightly more efficient, since you only need to call two surefire executions.

Another thing that I would say, it would probably be better for you to use the maven-fault-tolerant plug-in to perform your integration tests, because at some point in time you may want to do some preliminary and subsequent integration checks, and fail-safe is intended for this use case (although it should be trivial to switch further down the line)

+17
Aug 14 '12 at 8:27
source share

As an alternative to Stephen’s solution, if you don’t want the following message to appear in the log (which is actually a bit misleading, as you don’t miss the tests):

 [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ service-template --- [INFO] Tests are skipped. 

... then go this way:

  <execution> <id>default-test</id> <phase>none</phase> </execution> 
0
Jun 27 '19 at 12:21
source share



All Articles