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

前端 未结 2 978
闹比i
闹比i 2020-12-16 22:04

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


            org.apache.maven.plugins         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-16 22:53

    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 unit-tests to default-test or add

                
                    default-test
                    
                        true
                    
                
    

    either will have the same effect, though the unit-tests to default-test 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)

提交回复
热议问题