All Projects → haasted → Testlogcollectors

haasted / Testlogcollectors

Licence: mit
A framework for capturing log statements during tests. Compatible with most popular logging frameworks. Works with JUnit and TestNG

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Testlogcollectors

Scribe
The fastest logging library in the world. Built from scratch in Scala and programmatically configurable.
Stars: ✭ 304 (+880.65%)
Mutual labels:  logging, slf4j
Testcontainers Java
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
Stars: ✭ 5,478 (+17570.97%)
Mutual labels:  test-automation, junit
Logagent Js
Extensible log shipper with input/output plugins, buffering, parsing, data masking, and small memory/CPU footprint
Stars: ✭ 333 (+974.19%)
Mutual labels:  logging, logs
Rz Go
Ripzap - Fast and 0 allocs leveled JSON logger for Go ⚡️. Dependency free.
Stars: ✭ 256 (+725.81%)
Mutual labels:  logging, logs
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+2748.39%)
Mutual labels:  logging, logs
Stern
⎈ Multi pod and container log tailing for Kubernetes -- Friendly fork of https://github.com/wercker/stern
Stars: ✭ 268 (+764.52%)
Mutual labels:  logging, logs
Izumi
Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
Stars: ✭ 423 (+1264.52%)
Mutual labels:  logging, slf4j
action-junit-report
Reports junit test results as GitHub Pull Request Check
Stars: ✭ 103 (+232.26%)
Mutual labels:  test-automation, junit
Fluentlenium
FluentLenium is a website & mobile automation framework which extends Selenium to write reliable and resilient UI functional tests. This framework is React ready. Written and maintained by people who are automating browser-based tests on a daily basis.
Stars: ✭ 766 (+2370.97%)
Mutual labels:  junit, testng
Cabin
🌲 Cabin is the best JavaScript and Node.js logging service and logging npm package
Stars: ✭ 622 (+1906.45%)
Mutual labels:  logging, logs
jdbdt
JDBDT: Java Database Delta Testing
Stars: ✭ 12 (-61.29%)
Mutual labels:  test-automation, junit
Logbook
An extensible Java library for HTTP request and response logging
Stars: ✭ 822 (+2551.61%)
Mutual labels:  logging, logs
page-content-tester
Paco is a Java based framework for non-blocking and highly parallelized Dom testing.
Stars: ✭ 13 (-58.06%)
Mutual labels:  test-automation, junit
Vortex
🌀 Discord Moderation Bot
Stars: ✭ 283 (+812.9%)
Mutual labels:  logging, logs
XLT
XLT is an comprehensive load and performance test tool developed and maintained by Xceptance.
Stars: ✭ 39 (+25.81%)
Mutual labels:  test-automation, junit
Go Syslog
Blazing fast syslog parser
Stars: ✭ 370 (+1093.55%)
Mutual labels:  logging, logs
MasterAppiumFramework
Automation Testing | Mobile | Java | OOPS | Appium | TestNG | Maven | ExtentReport | Java mail API | Logging (Log4J2) | Design Patterns (Page Object Model, Singleton) | Page Factories | Jenkins | Data-Driven Testing using JSON file | Expected Data using XML file
Stars: ✭ 27 (-12.9%)
Mutual labels:  test-automation, testng
selenified
The Selenified Test Framework provides mechanisms for simply testing applications at multiple tiers while easily integrating into DevOps build environments. Selenified provides traceable reporting for both web and API testing, wraps and extends Selenium calls to more appropriately handle testing errors, and supports testing over multiple browser…
Stars: ✭ 38 (+22.58%)
Mutual labels:  test-automation, testng
Carina
Carina automation framework: Web, Mobile, API, DB
Stars: ✭ 549 (+1670.97%)
Mutual labels:  test-automation, testng
Scala Logging
Convenient and performant logging library for Scala wrapping SLF4J.
Stars: ✭ 804 (+2493.55%)
Mutual labels:  logging, slf4j

Log Collectors

Build Status Maven Central license Javadoc

Application logging is important and occasionally important enough to make it worth creating automated tests to verify it. Enter Log Collectors, which captures log records for inspection or verification during testing.

The framework hooks into any logger it is provided and intercepts its messages, making it possible to inspect or verify them.

It is applicable in situations where you want to

  • ensure that THE warning is emitted during an error
  • verify that the audit logs gets populated correctly

Log Collectors currently has support for the following libraries

It integrates directly with these testing frameworks:

The goals of the framework are

  • No forced dependencies.
  • Support for the most widespread logging frameworks

Feedback is appreciated. If you find the framework useful, or have suggestions for improving it, get in touch!

Usage

The following examples show how to add the framework to a test, provide it with the logger and inspect the log entries generated by testing a component.

JUnit 4

Logger logger = LogManager.getLogger("acme.Gizmo");

@Rule
public JUnit4LogCollector collector = new JUnit4LogCollector(logger);

@Test
public void testGizmo() {
    Gizmo gizmo = new Gizmo();
    gizmo.run();

    List<LogEvent> rawLogs = (List<LogEvent>) collector.getRawLogs();
    assertTrue(rawLogs.stream().noneMatch(l -> l.getLevel() == Level.ERROR));
}

JUnit 5

@LogCollectorExtension
public class GizmoTest {
    Logger logger = LogManager.getLogger("acme.Gizmo");

    JUnit5LogCollector collector = new JUnit5LogCollector(logger);

    @Test
    void testGizmo() {
        Gizmo gizmo = new Gizmo();
        gizmo.run();

        List<LogEvent> rawLogs = (List<LogEvent>) collector.getRawLogs();
        assertTrue(rawLogs.stream().noneMatch(l -> l.getLevel() == Level.ERROR));
    }
}

Note for Kotlin/JUnit 5 Users

To allow the extension to pick-up your Collector, the property must be annotated so reflection works correctly:

    @JvmField
    val collector = JUnit5LogCollector(logger)

See: https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html#instance-fields

TestNG

@Test
@Listeners(TestNGLogCollector.class)
public class GizmoTest {

    final static Logger logger = LoggerFactory.getLogger("acme.Gizmo");

    @BeforeTest
    public void captureLogger() {
        TestNGLogCollector.setLogSource(logger);
    }

    public void testGizmo() {
        Gizmo gizmo = new Gizmo();
        gizmo.run();

        List<LogEvent> rawLogs = (List<LogEvent>) TestNGLogCollector.getRawLogs();
        assertTrue(rawLogs.stream().noneMatch(l -> l.getLevel() == Level.ERROR));
    }
}

Installation

Log Collectors is available from Maven Central.

Maven installation

<dependency>
    <groupId>dk.bitcraft</groupId>
    <artifactId>LogCollector</artifactId>
    <version>0.9.0</version>
    <scope>test</scope>
</dependency>

Gradle installation

testCompile 'dk.bitcraft:LogCollector:0.9.0'

Future work

  • Come up with a better name for the framework.
  • Improve Javadoc and documentation.
  • Discover the intricacies of the various logging frameworks in real-world settings and adapt to them.
  • Avoid the ugly cast in getRawLogs.
  • Detect SLF4j's NOPLogger and replace it with SimpleLogger
  • Any ideas? Get in touch!
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].