What does the “default-test” stand for in the maven-surefire plugin

左心房为你撑大大i 提交于 2019-11-29 04:14:39

People wanted to have a way to override the default built-in executions of plugins within Maven.

Maven 3 (or it may have been introduced as early as 2.1.0 or 2.2.0) solved this by defining a default execution id for each plugin execution added to the effective pom by the packaging's lifecycle.

The name of this implicit id is always default-_____ I cannot recall the exact rule that it is generated for.

You can therefore override the packaging's injected executions by defining a matching 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>

either will have the same effect, though the <id>unit-tests</id> to <id>default-test</id> solution will be slightly more performant as you only need to invoke two executions of surefire.

The other thing I would point out is you would probably be better off using maven-failsafe-plugin to execute your integration tests as at some point in time you may want to do some stuff pre & post integration testing, and failsafe is designed for that use case (though it should be trivial to switch further down the line)

Alternatively to the Stephen's solution, if you don't want the following message to be displayed in the log (which in fact is a bit misleading since you are not skipping 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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!