1 package test.configuration; 2 3 import org.testng.Assert; 4 import org.testng.TestListenerAdapter; 5 import org.testng.TestNG; 6 import org.testng.annotations.Test; 7 8 /** 9 * Verify that a base class with a BeforeGroups method only gets invoked 10 * once, no matter how many subclasses it has 11 * 12 * Created on Jan 23, 2007 13 * @author <a href="mailto:cedric@beust.com">Cedric Beust</a> 14 */ 15 public class BaseGroupsTest { 16 17 @Test verifySingleInvocation()18 public void verifySingleInvocation() { 19 TestNG tng = new TestNG(); 20 tng.setVerbose(0); 21 tng.setTestClasses(new Class[] { 22 BaseGroupsASampleTest.class, 23 BaseGroupsBSampleTest.class, 24 }); 25 TestListenerAdapter tla = new TestListenerAdapter(); 26 tng.addListener(tla); 27 28 tng.run(); 29 30 Assert.assertEquals(Base.m_count, 1); 31 } 32 ppp(String s)33 private static void ppp(String s) { 34 System.out.println("[BaseGroupsTest] " + s); 35 } 36 } 37