我们可以在执行maven-surefire-plugin之前执行exec-maven-plugin吗? [英] Can we execute exec-maven-plugin before maven-surefire-plugin?
Is it possible to run exec-maven-plugin before maven-surefire-plugin, what I observe during my run is maven-surefire-plugin is executing first even though the sequence in tag is second. My scenario is to execute JAVA CLASS (using exec-maven-plugin ) which generates my testng.xml and can run that using (maven-surefire-plugin).
First of all, if you have an execution of the
exec-maven-plugin bound to the
test phase, it is normal that this execution is performed after the one of the
maven-surefire-plugin. The reason is that you're likely dealing with a project of packaging
jar, which has a default binding of the Surefire Plugin to the
test phase. This default execution is always the first one invoked, regardless of where the plugin is declared in the POM. In the logs, you will spot this execution with an id of
There is a way to perform actions before the tests are run by leveraging the phases invoked before the phase
test. In your case, your goal is to generate a test resource, the
testng.xml, so it would be appropriate to use the
generate-test-resources phase, whose purpose is to create resources that are needed for the tests. Therefore, you just need to specify
Then, you can use the generated
testng.xml with the
suiteXmlFiles element, see Using Suite XML Files