Class LogCapturing

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public final class LogCapturing
    extends java.lang.Object
    implements org.junit.rules.TestRule
    JUnit TestRule to make log lines appear only when the test failed.

    Use this in test by adding a public field annotated with @TestRule:

    
       @Rule public final LogCapturing logCapturing = new LogCapturing();
     

    Requires Logback and configuration like the following the logback-test.xml:

    
         <appender name="CapturingAppender" class="akka.actor.testkit.typed.internal.CapturingAppender" />
    
         <logger name="akka.actor.testkit.typed.internal.CapturingAppenderDelegate" >
           <appender-ref ref="STDOUT"/>
         </logger>
    
         <root level="DEBUG">
             <appender-ref ref="CapturingAppender"/>
         </root>
     
    • Constructor Summary

      Constructors 
      Constructor Description
      LogCapturing()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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

      • LogCapturing

        public LogCapturing()
    • 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