Maven TestNG project, pass command line arguments to testng.xml file

前端 未结 1 1428
夕颜
夕颜 2021-01-22 00:11

I have a Maven TestNG project, and am trying pass couple of command line arguments into the testng.xml file.

The testng.xml file looks like below:



        
相关标签:
1条回答
  • 2021-01-22 00:40

    TestNG and surefire are not supporting the ${var} notation.

    But you can use the filtering feature of Maven. Then you'll have to choose the modified resource:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Test_Project</groupId>
    <artifactId>TP_X</artifactId>
    <version>1.0-SNAPSHOT</version>
      <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <sourceDirectory>${src.dir}</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <suiteXmlFiles>
                       <suiteXmlFile>target/test-classes/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
      </build>
    </project>
    

    Note the difference between testResources and resources: How do I filter test resources in maven?

    0 讨论(0)
提交回复
热议问题