Timber-JUnit-Rule

JUnit TestRule that pipes Android Timber logs to the standard console

Лицензия

Лицензия

Категории

Категории

JUnit Тестирование компонентов Сеть
Группа

Группа

net.lachlanmckee
Идентификатор

Идентификатор

timber-junit-rule
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

aar
Описание

Описание

Timber-JUnit-Rule
JUnit TestRule that pipes Android Timber logs to the standard console
Ссылка на сайт

Ссылка на сайт

https://github.com/LachlanMcKee/timber-junit-rule
Система контроля версий

Система контроля версий

https://github.com/LachlanMcKee/timber-junit-rule

Скачать timber-junit-rule

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.lachlanmckee/timber-junit-rule/ -->
<dependency>
    <groupId>net.lachlanmckee</groupId>
    <artifactId>timber-junit-rule</artifactId>
    <version>1.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/net.lachlanmckee/timber-junit-rule/
implementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
// https://jarcasting.com/artifacts/net.lachlanmckee/timber-junit-rule/
implementation ("net.lachlanmckee:timber-junit-rule:1.0.1")
'net.lachlanmckee:timber-junit-rule:aar:1.0.1'
<dependency org="net.lachlanmckee" name="timber-junit-rule" rev="1.0.1">
  <artifact name="timber-junit-rule" type="aar" />
</dependency>
@Grapes(
@Grab(group='net.lachlanmckee', module='timber-junit-rule', version='1.0.1')
)
libraryDependencies += "net.lachlanmckee" % "timber-junit-rule" % "1.0.1"
[net.lachlanmckee/timber-junit-rule "1.0.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

Timber JUnit-Rule

This library provides a JUnit TestRule that plants a temporary Timber tree that pipes any logs sent via Timber to the standard System.out. Once a unit test has completed, the Timber tree is removed to avoid logging unintended test cases.

The rule is extremely useful for Android JUnit tests, as the Timber logs do not show without planting a tree.

Usage

Using the library is very straight forward. An example is as follows:

public class TestExample {
    @Rule
    public TimberTestRule timberTestRule = TimberTestRule.builder()
            .minPriority(Log.ERROR)
            .showThread(true)
            .showTimestamp(false)
            .onlyLogWhenTestFails(true)
            .build();
}

There are also several factory methods which cover many common cases. These are:

public class TestExample {
    @Rule
    public TimberTestRule logAllAlwaysRule = TimberTestRule.logAllAlways();
    @Rule
    public TimberTestRule logAllOnFailuresRule = TimberTestRule.logAllWhenTestFails();
    @Rule
    public TimberTestRule logErrorsAlwaysRule = TimberTestRule.logErrorsAlways();
    @Rule
    public TimberTestRule logErrorsOnFailuresRule = TimberTestRule.logErrorsWhenTestFails();
}

Configuration

As seen in the example above, there are many ways to modify the output using the following behaviours:

  • The minimum log level to output.
  • Whether thread ids are shown.
  • Whether timestamps are shown.
  • Whether to always log, or only log when a unit test fails.

Download

This library is available on Maven, you can add it to your project using the following gradle dependencies:

testCompile 'net.lachlanmckee:timber-junit-rule:1.0.1'

Версии библиотеки

Версия
1.0.1
1.0.0