I am trying to run TestNG tests in Maven. here is my configuration:
pom.xml:
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
This is the testNG conf file:
<suite name="Suite1">
<test name="Test1">
<groups>
<run>
<include name="Setup" />
<include name="Material" />
</run>
</groups>
<packages>
<package name="coloright.hibernate.*" />
</packages>
</test>
when I run with eclipse – no problem.
when I run with mvn test – all test run successfully, but build failed with error:
suiteXmlFiles is configured, but there is no TestNG dependency
Please help
Best Answer
Looks like you are hitting this surefire bug, which contrary to the status looks to be still open.
The bug appears if surefire is unable to find the file specified in
<suiteXmlFile>
. Could you try just specifyingtestng.xml
omittingsrc/test/resources
to see if that helps? The documentation is silent on how this location is to be specified - whether it should be relative to the base directory or relative to test resources folder.