aweXpect.Logging
aweXpect.Logging contains expectations for the log records that are
written with Microsoft.Extensions.Logging.
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 Expect.That(collector).LoggedWarning();
A failing expectation lists the collected records. If only an error was logged, LoggedWarning() would
fail with:
Failure message
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() |
Documentation
The full documentation is available at docs.testably.org:
- Log records:
LoggedandDidNotLogon the records of aFakeLogCollector