Reputation: 1077
I see a lot of posts on here about running a TestNG suite using Maven surefire plugin. The examples say to add this to the pom:
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testSuite}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
And then this to the command line:
mvn test -DtestSuite=myCustomSuite.xml
My problem with this is that it ties you to using the TestNG suite... For example, if I want to run with groups like this:
mvn test -Dgroups=myGroup
I get this error:
maven-surefire-plugin:2.18.1:test failed: testSuiteXmlFiles0 has null value
I want to be able to run, from command line, passing in either a suite path or groups.
Upvotes: 7
Views: 14828
Reputation: 24128
For some reason, the accepted answer didn't work for me. I used something like following.
mvn test -Dgroups=myGroup -DtestSuite=" "
Upvotes: 0
Reputation: 5740
Instead of using your surefire configuration with a property, you can:
mvn test -DtestSuite=myCustomSuite.xml
by mvn test -Dsurefire.suiteXmlFiles=myCustomSuite.xml
. See Surefire documentationmvn test -Dgroups=myGroup
.As the surefire configuration will be removed, the error testSuiteXmlFiles0 has null value
won't be present with the -Dgroup
option.
You can also use maven profiles which will configure surefire plugin depending on which property you pass to maven.
<profiles>
<profile>
<id>suite</id>
<activation>
<property>
<name>testSuite</name>
</property>
</activation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testSuite}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</profile>
</profiles>
Upvotes: 9