I want to run single test class from command line using Maven and TestNG
Things that doesn\'t work:
mvn -Dtest=ClassName test
I have de
I didn't test with TestNG 5.12.1 but I can say that running a single test using the test parameter and tests from groups using the groups parameter works with TestNG 5.14.2 (and surefire 2.6) (groups doesn't work in TestNG 5.14)
Here is the pom.xml I'm using:
4.0.0
com.stackoverflow
Q4159948
1.0-SNAPSHOT
Q4159948
http://maven.apache.org
1.6
1.6
org.testng
testng
5.14.2
test
org.apache.maven.plugins
maven-surefire-plugin
2.6
With a simple AppTest as follow:
import org.testng.annotations.*;
public class AppTest {
@BeforeClass
public void setUp() {
// code that will be invoked when this test is instantiated
}
@Test(groups = { "fast" })
public void aFastTest() {
System.out.println("Fast test");
}
@Test(groups = { "slow" })
public void aSlowTest() {
System.out.println("Slow test");
}
}
Both
$ mvn test -Dtest=AppTest
and
$ mvn test -Dgroups=slow
produce the expected result.