Logging with a throwable calls Log and you can't stop it
Timber 3.1.0
uprootAll disables the logging, this works with, say Timber.w(String) but not Timber.w(Throwable, String). Here is a test that demonstrates this when run without Robolectric:
import org.junit.Test;
import java.util.concurrent.atomic.AtomicInteger;
import timber.log.Timber;
import static org.junit.Assert.assertEquals;
public final class TimberProblem {
@Test
public void OK() {
final AtomicInteger i = new AtomicInteger();
Timber.uprootAll();
Timber.plant(new Timber.Tree() {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
i.incrementAndGet();
}
});
Timber.w("Test");
assertEquals(1, i.get());
}
@Test
public void Problem() {
final AtomicInteger i = new AtomicInteger();
Timber.uprootAll();
Timber.plant(new Timber.Tree() {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
i.incrementAndGet();
}
});
Timber.w(new Exception(), "Test"); //java.lang.RuntimeException: Method getStackTraceString in android.util.Log not mocked.
assertEquals(1, i.get());
}
}