Reputation: 8520
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
Upvotes: 3
Views: 9412
Reputation: 430
Please check your output folder in build path should be like /target/test-classes.
Also check your pom entry for this and update accordingly:
<testSourceDirectory>src</testSourceDirectory>
<outputDirectory>target/test-classes</outputDirectory>
<resources>
<resource>
<directory>src</directory>
</resource>
</resources>
Upvotes: 0
Reputation: 29689
You could try this. Not sure if it would work for you but I do this sometimes, although it seems like its redundant:
<suiteXmlFiles>
<suiteXmlFile>
${project.build.testOutputDirectory}/testng.xml
</suiteXmlFile>
</suiteXmlFiles>
Upvotes: 1
Reputation: 1
Add the surefire-testng dependency to your pom.xml :
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.16</version>
</dependency>
Upvotes: 0
Reputation: 52665
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 specifying testng.xml
omitting src/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.
Upvotes: 2