Interface LogCapturing

All Superinterfaces:
org.scalatest.BeforeAndAfterAll, org.scalatest.SuiteMixin

public interface LogCapturing extends org.scalatest.BeforeAndAfterAll
Mixin this trait to a ScalaTest test to make log lines appear only when the test failed.

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


     <appender name="CapturingAppender" class="org.apache.pekko.actor.testkit.typed.internal.CapturingAppender" />

     <logger name="org.apache.pekko.actor.testkit.typed.internal.CapturingAppenderDelegate" >
       <appender-ref ref="STDOUT"/>
     </logger>

     <root level="DEBUG">
         <appender-ref ref="CapturingAppender"/>
     </root>
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    May be called to explicitly clear the captured logs.
    boolean
    If true, the logs will be cleared after each test.
    void
     
    org.scalatest.Outcome
    withFixture(org.scalatest.TestSuite.NoArgTest test)
     

    Methods inherited from interface org.scalatest.BeforeAndAfterAll

    beforeAll, invokeBeforeAllAndAfterAllEvenIfNoTestsAreExpected, org$scalatest$BeforeAndAfterAll$_setter_$invokeBeforeAllAndAfterAllEvenIfNoTestsAreExpected_$eq, run

    Methods inherited from interface org.scalatest.SuiteMixin

    expectedTestCount, nestedSuites, rerunner, runNestedSuites, runTest, runTests, styleName, suiteId, suiteName, tags, testDataFor, testNames
  • Method Details

    • afterAll

      void afterAll()
      Specified by:
      afterAll in interface org.scalatest.BeforeAndAfterAll
    • clearCapturedLogs

      void clearCapturedLogs()
      May be called to explicitly clear the captured logs.

      Useful for when logs are not cleared after each test. If clearing after every test is desirable, overriding clearLogsAfterEachTest() is preferable.

    • clearLogsAfterEachTest

      boolean clearLogsAfterEachTest()
      If true, the logs will be cleared after each test.

      This is not enabled by default for Scala tests, since state may be shared between sequential tests, and logs from earlier tests may be important.

    • super$afterAll

      void super$afterAll()
    • withFixture

      org.scalatest.Outcome withFixture(org.scalatest.TestSuite.NoArgTest test)