1 package test.reports;
2 
3 import org.testng.Assert;
4 import org.testng.Reporter;
5 import org.testng.TestNG;
6 import org.testng.annotations.Test;
7 
8 import test.SimpleBaseTest;
9 
10 import java.util.List;
11 
12 /**
13  * Make sure that Reporter.log() in listeners don't get discarded.
14  */
15 public class ReporterLogTest extends SimpleBaseTest {
16 
17   @Test
shouldLogFromListener()18   public void shouldLogFromListener() {
19     TestNG tng = create(ReporterLogSampleTest.class);
20     tng.run();
21     List<String> output = Reporter.getOutput();
22     boolean success = false;
23     for(String s : output) {
24       if (s.contains("Log from listener")) {
25         success = true;
26         break;
27       }
28     }
29     Assert.assertTrue(success);
30 //    System.out.println(output);
31   }
32 }
33