CTRL4TestNG: Current Test Result Logger for TestNG

CTRL4TestNG provides an SLF4J Logger that can be used from any TestNG method tied to an ITestResult, namely Before, After, and Test annotations. Each separate method will have its own unique Logger and can be used with TestNG's parallel testing support making it clear which logs came from which method even when data-driven.

License

License

Categories

Categories

TestNG Unit Testing
GroupId

GroupId

io.github.mfulton26.ctrl4testng
ArtifactId

ArtifactId

ctrl4testng
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

CTRL4TestNG: Current Test Result Logger for TestNG
CTRL4TestNG provides an SLF4J Logger that can be used from any TestNG method tied to an ITestResult, namely Before, After, and Test annotations. Each separate method will have its own unique Logger and can be used with TestNG's parallel testing support making it clear which logs came from which method even when data-driven.
Project URL

Project URL

https://mfulton26.github.io/ctrl4testng/
Source Code Management

Source Code Management

https://github.com/mfulton26/ctrl4testng

Download ctrl4testng

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.mfulton26.ctrl4testng/ctrl4testng/ -->
<dependency>
    <groupId>io.github.mfulton26.ctrl4testng</groupId>
    <artifactId>ctrl4testng</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.mfulton26.ctrl4testng/ctrl4testng/
implementation 'io.github.mfulton26.ctrl4testng:ctrl4testng:1.1'
// https://jarcasting.com/artifacts/io.github.mfulton26.ctrl4testng/ctrl4testng/
implementation ("io.github.mfulton26.ctrl4testng:ctrl4testng:1.1")
'io.github.mfulton26.ctrl4testng:ctrl4testng:jar:1.1'
<dependency org="io.github.mfulton26.ctrl4testng" name="ctrl4testng" rev="1.1">
  <artifact name="ctrl4testng" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.mfulton26.ctrl4testng', module='ctrl4testng', version='1.1')
)
libraryDependencies += "io.github.mfulton26.ctrl4testng" % "ctrl4testng" % "1.1"
[io.github.mfulton26.ctrl4testng/ctrl4testng "1.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.10
org.testng : testng jar 6.8.17
com.google.guava : guava jar 18.0

test (4)

Group / Artifact Type Version
com.google.inject : guice jar 3.0
org.mockito : mockito-core jar 1.10.19
com.google.truth : truth jar 0.25
ch.qos.logback : logback-classic jar 1.1.2

Project Modules

There are no modules declared in this project.

CTRL4TestNG: Current Test Result Logger for TestNG

Build Status Coverage Status Maven Central

Join the chat at https://gitter.im/mfulton26/ctrl4testng

The Current Test Result Logger for TestNG (CTRL4TestNG) provides an SLF4J Logger that can be used from any TestNG method tied to an ITestResult (i.e. methods annotated as Test, BeforeClass, AfterClass, etc.). Each separate method will have its own unique Logger and can be used with TestNG's parallel testing support making it clear which logs came from which method even when data-driven by means of DataProviders and/or Factories.

Usage

Simply change your SLF4J Logger initializations in your code to use CTRL4TestNG's LOGGER constant instead of SLF4J's LoggerFactory. See CTRL4TestNGExampleTest for an example including example output.

As CTRL4TestNG's LOGGER constant is a public static you can also use it through static import.

Logger Category Format

CTRL4TestNG forwards logging requests to a unique Logger for each Before/After/Test TestNG method. Each method's logger is named using the following format:

[method-name]{[method-parameters]} on [class-instance-string] in [xml-suite-name]

The class-instance-string is either the test class's toString() return value, if overriden, or the test class's simple name.

Example Output

The following example output is from running CTRL4TestNGExampleTest with TestNG.

11:11:09.335 [main] INFO  log{} on DataDrivenClass{message=message 1} in ctrl4testng - message 1
11:11:09.339 [main] INFO  log{} on DataDrivenClass{message=message 2} in ctrl4testng - message 2
11:11:09.342 [main] INFO  info{message 1} on DataDrivenMethod{} in ctrl4testng - message 1
11:11:09.342 [main] INFO  info{message 2} on DataDrivenMethod{} in ctrl4testng - message 2
11:11:09.344 [main] ERROR error{} on Simple{} in ctrl4testng - this is an error log message
11:11:09.346 [main] INFO  info{} on Simple{} in ctrl4testng - this is an informational log message
11:11:09.347 [main] WARN  warn{} on Simple{} in ctrl4testng - this is a warning log message
11:11:09.349 [main] INFO  tearDownMethod{} on Simple{} in ctrl4testng - supports before and after methods too

Versions

Version
1.1
1.0