log-tracker

A junit 5 stub to help unit test log events and statements

Лицензия

Лицензия

Категории

Категории

Logging Библиотеки уровня приложения
Группа

Группа

com.callibrity.logging
Идентификатор

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

log-tracker
Последняя версия

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

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

log-tracker
A junit 5 stub to help unit test log events and statements
Ссылка на сайт

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

https://github.com/mwehby/junit5-log-test-stub
Система контроля версий

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

https://github.com/mwehby/junit5-log-test-stub

Скачать log-tracker

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

<!-- https://jarcasting.com/artifacts/com.callibrity.logging/log-tracker/ -->
<dependency>
    <groupId>com.callibrity.logging</groupId>
    <artifactId>log-tracker</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.callibrity.logging/log-tracker/
implementation 'com.callibrity.logging:log-tracker:1.0.1'
// https://jarcasting.com/artifacts/com.callibrity.logging/log-tracker/
implementation ("com.callibrity.logging:log-tracker:1.0.1")
'com.callibrity.logging:log-tracker:jar:1.0.1'
<dependency org="com.callibrity.logging" name="log-tracker" rev="1.0.1">
  <artifact name="log-tracker" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.callibrity.logging', module='log-tracker', version='1.0.1')
)
libraryDependencies += "com.callibrity.logging" % "log-tracker" % "1.0.1"
[com.callibrity.logging/log-tracker "1.0.1"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
org.slf4j : slf4j-api jar 1.7.25
ch.qos.logback : logback-classic jar 1.2.3
ch.qos.logback : logback-core jar 1.2.3
org.junit.jupiter : junit-jupiter-api jar 5.2.0

test (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-engine jar 5.2.0

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

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

junit5-log-test-stub

A junit 5 stub to help unit test log events and statements

See the following blog post for more information: https://www.callibrity.com/blog/how-to-unit-test-log-statements-with-junit5

The jar file can be pulled in and used via Maven Central Repository.

<dependency>
  <groupId>com.callibrity.logging</groupId>
  <artifactId>log-tracker</artifactId>
  <version>1.0.1</version>
</dependency>

Quick Summary CUT ( Class Under Test ) . In order to illustrate how to use the new JUnit 5 Extension model to unit test logging statements, let’s pretend we have the follow CUT.

public class CUT {

Logger logger = LoggerFactory.getLogger(CUT.class);

public void doNothingButLog() {
	logger.debug("Inside CUT.doNothingButLog");
}

public void doNothingButLogTwo() {
	logger.info("Start CUT.doNothingBugLogTwo");
	
	logger.info("End CUT.doNothingBugLogTwo");
}

}

Use the LogTrackerStub, which is a JUnit 5 Extension enabled class. It is used as follows:

public class CUTTest {

@RegisterExtension
LogTrackerStub logTrackerStub = LogTrackerStub.create().recordForLevel(LogTracker.LogLevel.INFO)
	.recordForType(CUT.class);


@Test
public void testCUTMethodOne() {
	logTrackerStub.recordForLevel(LogTracker.LogLevel.DEBUG);
	CUT classUnderTest = new CUT();
	classUnderTest.doNothingButLog();
	
	assertTrue(logTrackerStub.contains("Inside CUT.doNothingButLog"));
	assertEquals(1, logTrackerStub.size());
}

@Test
public void testCUTMethodTwo() {
	CUT classUnderTest = new CUT();
	classUnderTest.doNothingButLogTwo();
	assertTrue(logTrackerStub.contains("Start CUT.doNothingBugLogTwo"));
	assertTrue(logTrackerStub.contains("End CUT.doNothingBugLogTwo"));
	assertEquals(2, logTrackerStub.size());
	
}

}

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

Версия
1.0.1