All Projects → LachlanMcKee → timber-junit-rule

LachlanMcKee / timber-junit-rule

Licence: MIT license
A highly configurable JUnit Rule that outputs Timber logs to standard output

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to timber-junit-rule

rules4android
A collection of JUnit 4 Rules for Android Developers 🔬
Stars: ✭ 23 (-45.24%)
Mutual labels:  junit, junit-test
scalatest-junit-runner
JUnit 5 runner for Scalatest
Stars: ✭ 30 (-28.57%)
Mutual labels:  junit, junit-test
papertrail-timber
Pluggable timber tree for Papertrail logging
Stars: ✭ 20 (-52.38%)
Mutual labels:  timber, timber-tree
doc
QuickPerf documentation: https://github.com/quick-perf/doc/wiki/QuickPerf
Stars: ✭ 22 (-47.62%)
Mutual labels:  junit, junit-test
justtestlah
Dynamic test framework for web and mobile applications
Stars: ✭ 43 (+2.38%)
Mutual labels:  junit
next-go
Production ready blog + boilerplate for Next.js 3.X
Stars: ✭ 255 (+507.14%)
Mutual labels:  timber
xunit-to-junit
This Extensible Stylesheet Language Transformations can transform a xUnit.net v2 XML test results file into a JUnit test results file.
Stars: ✭ 21 (-50%)
Mutual labels:  junit
zerocode-hello-world
Zerocode YAML and JSON based declarative steps hello world rest api testing example - soap, database
Stars: ✭ 18 (-57.14%)
Mutual labels:  junit
spring-jooq-flyway-testcontainers-junit5
🚀 Example project with configured Spring Boot, JooQ, TestContainers, MySQL container and JUnit5
Stars: ✭ 29 (-30.95%)
Mutual labels:  junit
junit4git
Junit Extensions for Test Impact Analysis
Stars: ✭ 40 (-4.76%)
Mutual labels:  junit
jpa-unit
JUnit extension to test javax.persistence entities
Stars: ✭ 28 (-33.33%)
Mutual labels:  junit
osgi-testsuite
The OSGi Test Suite runs all JUnit tests in a given list of bundles
Stars: ✭ 15 (-64.29%)
Mutual labels:  junit
ResDelivery-Hilt-Coroutines-Mvvm-Single-Activity
This is a Sample Single Activity App (Multi Fragments) that uses Dagger-Hilt, Coroutines Flows, Paging 3 & Mvvm Clean Architecture
Stars: ✭ 28 (-33.33%)
Mutual labels:  timber
HiveRunner
An Open Source unit test framework for Hive queries based on JUnit 4 and 5
Stars: ✭ 244 (+480.95%)
Mutual labels:  junit
kafka-junit
JUnit rule for spinning up a Kafka broker
Stars: ✭ 97 (+130.95%)
Mutual labels:  junit
springboot-rest-api-angularjs-https
REST API https with Spring Boot and Angular JS. Use MySQL, Hibernate and Spring Security.
Stars: ✭ 38 (-9.52%)
Mutual labels:  junit
travis-ci-tutorial-java
Just to learn how to use travis-ci in a java project!
Stars: ✭ 38 (-9.52%)
Mutual labels:  junit
InstantAppStarter
Starter Project Structure for Android Instant app. https://blog.mindorks.com/android-mvp-architecture-with-instant-app-support-11ba48241a82
Stars: ✭ 44 (+4.76%)
Mutual labels:  timber
junit5-kubernetes
Use kubernetes pod from your Junit5 test classes
Stars: ✭ 40 (-4.76%)
Mutual labels:  junit
Instant-Weather
An Android weather application implemented using the MVVM pattern, Retrofit2, Dagger Hilt, LiveData, ViewModel, Coroutines, Room, Navigation Components, Data Binding and some other libraries from the Android Jetpack.
Stars: ✭ 677 (+1511.9%)
Mutual labels:  timber

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'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].