I'm using Timber with a DebugTree
and a ProductionTree
. All is fine and perfect in the running app.
I also succeed to use Timber in my JUnit test implementation, and that's fine (no real benefit, but it does work).
However, I would like to get the logs on the code under test
to be displayed in the JUnit log.
I tried to build a JUnitTree
and redirect timber logs to println(…)
, and setup the Timber JUnitTree
in @Before
function, but nothing worked. Any solution from the community?
Does my request make no sens, I didn't find anything about this need in the web (maybe I used wrong keywords).
The following
ConsoleTree
class can be used to forward Timber logs to standard output:For JUnit 4 a rule can be used to plant and uproot
ConsoleTree
automatically for each test:For JUnit 5 you can simply annotate JUnit test with the following
@TimberConsoleLog
annotation: