Skip to content
CodeKruPro

Choose a TestNG suite file from the command line

QuizMediumJava onlyAsked in: Accenture, Capgemini, Infosys, TCS, Wipro

The pom.xml configures Surefire like this:

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

How do you run regression.xml instead?

  • mvn test -DsuiteXmlFile=regression.xml
  • mvn test regression.xml
  • mvn test -Dtest=regression.xml
  • Edit pom.xml before every run

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in