Skip to content

About

Expectations for logging with Microsoft.Extensions.Logging for aweXpect.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aweXpect.Logging

Nuget Build Quality Gate Status Coverage Mutation testing badge

Expectations for logging with Microsoft.Extensions.Logging for aweXpect.

Installation

dotnet add package aweXpect.Logging

It does not include aweXpect itself. The examples assume global using static aweXpect.Expect;.

At a glance

// collect the log records with a FakeLogger from Microsoft.Extensions.Diagnostics.Testing
FakeLogCollector collector = new();
ILogger logger = new FakeLogger(collector);
logger.LogWarning("Retry limit reached");

// verify that a record with the log level was logged
await That(collector).LoggedWarning();

A failing expectation lists the collected records. If only an error was logged, LoggedWarning() would fail with:

Expected that collector
logged a record with level Warning at least once,
but it did not log any such record

Records:
[
  [Error] "Retry limit reached"
]

Overview

Expectation Subject Summary
Logged FakeLogCollector, FakeLogger logged at least one record with the log level, e.g. LoggedWarning()
DidNotLog FakeLogCollector, FakeLogger logged no record with the log level, e.g. DidNotLogError()
Then FakeLogCollector, FakeLogger logged further records after a matching record, in the given order
Within FakeLogCollector, FakeLogger reads the records repeatedly until the timeout, e.g. for a background service

Documentation

The full documentation is available at docs.testably.org:

  • Log records: Logged, DidNotLog, Then and Within on the records of a FakeLogCollector or FakeLogger

About

Expectations for logging with Microsoft.Extensions.Logging for aweXpect.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages