1 package test.multiplelisteners; 2 3 import org.testng.IReporter; 4 import org.testng.ISuite; 5 import org.testng.SuiteRunner; 6 import org.testng.TestListenerAdapter; 7 import org.testng.internal.IConfiguration; 8 import org.testng.xml.XmlSuite; 9 import test.listeners.ListenerAssert; 10 11 import java.lang.reflect.Field; 12 import java.util.List; 13 14 public class SimpleReporter implements IReporter 15 { 16 @Override generateReport(final List<XmlSuite> xmlSuites, final List<ISuite> suites, final String outputDirectory)17 public void generateReport(final List<XmlSuite> xmlSuites, final List<ISuite> suites, 18 final String outputDirectory) 19 { 20 for (final ISuite iSuite : suites) 21 { 22 try 23 { 24 final Field field = SuiteRunner.class.getDeclaredField("m_configuration"); 25 field.setAccessible(true); 26 final IConfiguration conf = (IConfiguration) field.get(iSuite); 27 ListenerAssert.assertListenerType(conf.getConfigurationListeners(), TestListenerAdapter.class); 28 } 29 catch (final Exception e) 30 { 31 throw new RuntimeException(e); 32 } 33 } 34 } 35 } 36