0

When running testng with mvn, I configured my workspace as required: My pom.xml file is configured with all the required dependencies and testng.xml contains all the required classes.

Yet, when I add a new test class, the testng.xml isn't updated automatically- Shouldn't it scan from the root for the corresponding tests? Or will I have to update the testng.xml file manually? (BTW, my workspace is configured according to the following post: How to call testng.xml file from pom.xml in Maven)

Community
  • 1
  • 1
Maoritzio
  • 1,142
  • 2
  • 13
  • 31

1 Answers1

1

The xml method gives you more granular control of your test sets. It will not be altered automatically, although eclipse will generate xml configs on the fly if you select say a folder and right click run as testng. If you would just like to run all testng annotated test and you have maven configured properly with surefire or failsafe, you don't even need an xml file. Just run "mvn verify" and all test should be run based on annotation. If this doesn't work, please post your surefire/failsafe pom sections.

If you want to configure a particular xml in maven, use something like (surefire or failsafe work the same.):

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${failsafe.version}</version>
                <configuration>
                    <argLine>-Xmx1024m</argLine>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>testng.xml</suiteXmlFile>
                                <!-- <groups>functest,perftest</groups> -->
                            </suiteXmlFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

If you do need more granular control, and would like to use an xml file specified by maven, you launch it via "verify -P MyProfile"

<profiles>
        <profile>
            <id>MyProfile</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>MyProfile.xml</suiteXmlFile>
                                <!-- <groups>functest,perftest</groups> -->
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>MyOtherProfile</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>MyOtherProfile.xml</suiteXmlFile>
                                <!-- <groups>functest,perftest</groups> -->
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
<profiles>
Rick
  • 426
  • 3
  • 8