Tibor17 commented on a change in pull request #112: Adding support for 
externally passed random seed and printing used seed on console
URL: https://github.com/apache/maven-surefire/pull/112#discussion_r212600811
 
 

 ##########
 File path: 
surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/TestNGSuiteTest.java
 ##########
 @@ -28,16 +28,23 @@
  * @author <a href="mailto:tibordig...@apache.org";>Tibor Digana (tibor17)</a>
  * @since 2.19
  */
-public class TestNGSuiteTest {
-       private static final AtomicInteger counter = new AtomicInteger();
+public class TestNGSuiteTest
+{
+    private static final AtomicInteger counter = new AtomicInteger();
 
-       @Test
-       public void shouldRunAndPrintItself()
-               throws Exception
-       {
-               System.out.println( getClass().getSimpleName() + 
"#shouldRunAndPrintItself() "
-                                                               + 
counter.incrementAndGet() + ".");
+    @Test
+    public void shouldRunAndPrintItself() throws Exception
+    {
+        String message = String.format(
+                "%s#shouldRunAndPrintItself() %d.",
+                getClass().getSimpleName(),
+                counter.incrementAndGet()
+        );
+        TimeUnit.SECONDS.sleep( 1 );
 
-               TimeUnit.SECONDS.sleep( 2 );
-       }
+        synchronized ( System.out )
 
 Review comment:
   @cardil 
   Thx for pointing out the synchronization issue with `System.out`.
   I have noticed the same problem yesterday, see 
https://github.com/cbeust/testng/issues/1908
   Treating the stream in test would fix our builds but we still have this 
issue on Ubuntu and not on Windows. Does it mean that the Sysout should be 
synchronized in the application run? We are setting the delegate via 
`System.setOut()` and the delegate in `ForkingRunListener` is synchronized. Why 
we do not see same issue in JUnit tests?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to