1 package test; 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 import org.testng.collections.Sets; 9 10 import java.util.HashSet; 11 import java.util.List; 12 import java.util.Set; 13 14 public class NestedStaticTest extends SimpleBaseTest { 15 16 @Test nestedClassShouldBeIncluded()17 public void nestedClassShouldBeIncluded() { 18 TestNG tng = create(NestedStaticSampleTest.class); 19 TestListenerAdapter tla = new TestListenerAdapter(); 20 tng.addListener(tla); 21 tng.run(); 22 23 Set<String> expected = new HashSet<String>() {{ 24 add("nested"); 25 add("f"); 26 }}; 27 Set<String> actual = Sets.newHashSet(); 28 List<ITestResult> passedTests = tla.getPassedTests(); 29 for (ITestResult t : passedTests) { 30 actual.add(t.getMethod().getMethodName()); 31 } 32 33 Assert.assertEquals(actual, expected); 34 } 35 } 36