How to run the specified testNG
case by code? The following code:
public class TestNGTest {
@Test
public void test() {
System.out.println("test ########");
}
@Test
public void test2() {
System.out.println("test2 ************");
}
public static void main(String[] args) throws Exception {
TestNG testSuite = new TestNG();
testSuite.setTestClasses(new Class[] { TestNGTest.class });
testSuite.setDefaultSuiteName("setDefaultSuiteName");
testSuite.setDefaultTestName("setDefaultTestName");
testSuite.run();
}
}
This would run both the test cases. How to specifically run "test2" only?
Expected output:
test2 ************