是否有可能在maven-surefire-plugin之前运行exec-maven-plugin,我在运行过程中观察到的是maven-surefire-plugin首先执行,尽管标签中的序列是第二位。我的场景是执行JAVA类(使用execute plugin),它生成testng.xml并可以使用(maven-surefire-plugin)运行。
发布于 2016-12-21 09:36:02
首先,如果要执行绑定到exec-maven-plugin阶段的test,则通常在maven-surefire-plugin阶段之后执行该执行。原因是您可能要处理一个将jar、,该插件具有默认的绑定。打包到test阶段的项目。这个默认的执行总是第一个被调用的,不管插件在POM中声明在哪里。在日志中,您将使用default-test id来识别此执行。
有一种方法可以通过利用test在测试运行之前执行操作。在您的示例中,您的目标是生成一个测试资源testng.xml,因此使用generate-test-resources阶段是合适的,其目的是创建测试所需的资源。因此,您只需指定
<phase>generate-test-resources</phase>来执行生成exec-maven-plugin的testng.xml。
然后,可以将生成的testng.xml与suiteXmlFiles元素一起使用,请参阅使用Suite XML文件
发布于 2021-02-23 00:53:53
我就是这样实施的:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/java/BeforeSuite</source> <!-- source folder where Before Suite scripts are saved -->
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>before-test-suite-scripts</id>
<phase>generate-test-resources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>BeforeSuite.HelloBeforeSuiteScript</mainClass> <!-- <packagename>.<className> -->
</configuration>
</execution>
</executions>
</plugin>
当运行mvn clean verify时,测试套件脚本将在测试套件执行之前运行。在这里输入图像描述
https://stackoverflow.com/questions/41258985
复制相似问题