xGIx
xGIx

Reputation: 539

Possible to target specific TestNG.xml files via Maven POM File?

Possible to target only one of the two TestNG xml files listed within my Maven POM File?

My Maven POM file points to two xml files: uat.xml and preprod.xml, how do i target only one of the xml files using maven commands such as mvn clean compile test?

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <fork>true</fork>
                    <!--<executable>C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe</executable> -->
                    <executable>${env.JAVA_HOME}\bin\javac.exe</executable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>uat.xml</suiteXmlFile>
                        <suiteXmlFile>preprod.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <testErrorIgnore>false</testErrorIgnore>
                    <testFailureIgnore>false</testFailureIgnore>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Upvotes: 0

Views: 179

Answers (1)

user3821521
user3821521

Reputation:

See below. You will reference the file by name. So,

mvn clean test -Dtestfile=uat.xml

<configuration>
  <suiteXmlFiles>
    <suiteXmlFile>${testfile}</suiteXmlFile>
  </suiteXmlFiles>
</configuration>

Upvotes: 2

Related Questions