1 package test.reports; 2 3 import org.testng.*; 4 import org.testng.annotations.Listeners; 5 import org.testng.annotations.Test; 6 7 import java.util.Set; 8 9 @Listeners(ReporterTest.class) 10 public class ReporterTest extends TestListenerAdapter { onStart(ITestContext testContext)11 @Override public void onStart (ITestContext testContext) { 12 Reporter.log ("foo"); 13 } 14 @Test testMethod()15 public void testMethod() { 16 Reporter.log ("bar"); // This line is required. Else the log that was triggered from onStart() would never be 17 // persisted at all. 18 Assert.assertTrue (Reporter.getOutput ().size () == 2); 19 } 20 } 21