Java – how to parameterize the Maven surefire plug-in so that I can choose which TestNG suite to run

I have many test suites in TestNG These are XML files When running integration tests from maven, I want to be able to select multiple XML suites

For now, I can add the suite file to POM XML, as follows:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <suiteXmlFiles>
      <suiteXmlFile>${pathToMySuiteFile_1}</suiteXmlFile>
      <suiteXmlFile>${pathToMySuiteFile_1}</suiteXmlFile>
    </suiteXmlFiles>
  </configuration>
</plugin>

This solution has some limitations I can only change me in POM The path to the test suite defined in XML So in my example, it always has to be two files I can't run. It can be said that there are five sets or only one

Is there any way in POM Parameterize the entire part "suitexmlfiles" in XML?

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <suiteXmlFiles>
      ${multiple_paths_ToMySuiteFiles}
    </suiteXmlFiles>
  </configuration>
</plugin>

Running everything that matches a given test group is not an option for me: I don't want to load all the suites I have and then run the selected tests using the groups in the TestNG suite The reason is that the report generated after running all test suites with group filters is different from the report that only runs the selected test suite

Solution

According to suitexmlfiles of user property, you can use:

mvn test -Dsurefire.suiteXmlFiles=test1.xml,test2.xml
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>