org.junit.contrib.java.lang.system
Class DisallowWriteToSystemOut

java.lang.Object
  extended by org.junit.contrib.java.lang.system.DisallowWriteToSystemOut
All Implemented Interfaces:
org.junit.rules.TestRule

public class DisallowWriteToSystemOut
extends Object
implements org.junit.rules.TestRule

DisallowWriteToSystemOut lets a test fail if it tries to write something to System.out.

For that purpose you only have to add DisallowWriteToSystemOut rule to your test class

 public class TestClass {
   @Rule
   public final DisallowWriteToSystemOut disallowWriteToSystemOut
     = new DisallowWriteToSystemOut();

   @Test
   public void this_test_fails() {
     System.out.println("some text");
   }
 }
 

Since:
1.14.0
See Also:
DisallowWriteToSystemErr

Constructor Summary
DisallowWriteToSystemOut()
           
 
Method Summary
 org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DisallowWriteToSystemOut

public DisallowWriteToSystemOut()
Method Detail

apply

public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
                                               org.junit.runner.Description description)
Specified by:
apply in interface org.junit.rules.TestRule


Copyright © 2011–2018. All rights reserved.