kroe761
kroe761

Reputation: 3534

Use custom TestNG.xml file instead of the one generated automatically?

I have a Maven/TestNG/Selenium project in Eclipse. When I run the project as a TestNG test, I see this in the console:

[TestNG] Running:    
    /private/var/folders/ly/hg5d7s916xs2f9c1l95ndqcm0000gn/T/testng-eclipse-1560914389/testng-customsuite.xml

Awesome. So I copied that file to the top level folder (next to my pom.xml), and re-ran the project. But I see this:

[TestNG] Running:
    /private/var/folders/ly/hg5d7s916xs2f9c1l95ndqcm0000gn/T/testng-eclipse-631698178/testng-customsuite.xml

It generated a new XML file. But, I need to set parameters and other things for my tests to run in a distributed fashion. How can I use the XML file that I edited? Thanks!

Upvotes: 1

Views: 1204

Answers (1)

Maciej Kowalski
Maciej Kowalski

Reputation: 26492

Create your own file called testng.xml and put it in the src/test/resources.

You might need to install the maven-surefire-plugin in order to make that work additionally.

<plugins>
    [...]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
    [...]
</plugins>

Update

If you want to specify custom suite from Eclipse, then you have to go to

Debug Configuration -> New TestNG Test -> Suite

Once you select the Suite option you can choose any suite xml file which is inside your project.

Upvotes: 2

Related Questions