I have problems setting up my project for testng usage. Background is that I want to execute my test.xml with maven command line. I use this plugin within the build section of my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
However... when I call mvn clean test -DxmlSuiteFile=test.xml
all my unit tests are executed but the test.xml is untouched.
when I change the version of surefire to 2.22.2
everything works fine.
BUT I get the message: testSuiteXmlFiles0 has null value
when running only mvn test
I am confused how to get that to run with the surefire 3.0.0-M5 ?
CodePudding user response:
-DxmlSuiteFile=test.xml
is not required if it already defined in pom.xml.
Try to define surefire testNG provider explicitly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
test.xml
file should be in the project root.
See also: https://maven.apache.org/surefire/maven-surefire-plugin/examples/providers.html