1 package test.dependsongroup; 2 3 import org.testng.Assert; 4 import org.testng.ITestResult; 5 import org.testng.TestListenerAdapter; 6 import org.testng.TestNG; 7 import org.testng.annotations.Test; 8 9 import test.SimpleBaseTest; 10 11 public class DependsOnGroupsTest extends SimpleBaseTest { 12 13 @Test methodsShouldBeGroupedByClasses()14 public void methodsShouldBeGroupedByClasses() { 15 TestNG tng = create(new Class[] { 16 ZeroSampleTest.class, FirstSampleTest.class, SecondSampleTest.class 17 }); 18 19 TestListenerAdapter tla = new TestListenerAdapter(); 20 tng.addListener(tla); 21 tng.run(); 22 String[] expected = new String[] { 23 "zeroA", "zeroB", 24 "firstA", "firstB", 25 "secondA", "secondB" 26 }; 27 for (int i = 0; i < expected.length; i++) { 28 ITestResult testResult = tla.getPassedTests().get(i); 29 Assert.assertEquals(testResult.getMethod().getMethodName(), expected[i]); 30 } 31 } 32 } 33