Stravaig Logging Diagnostics

Diagnostics for examining logs in automated tests.

XUnit Extensions

Available from v2.1 in package Stravaig.Extensions.Logging.Diagnostics.XUnit

ITestOutputHelper.WriteLogs()

Writes the logs to XUnit’s test output helper.

Arguments

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class ThingamajigTests
{
    private ITestOutputHelper _output;

    public ThingamajigTests(ITestOutputHelper output)
    {
        _output = output;
    }

    [Fact]
    public void TestTheThing()
    {
        // Arrange: Set up logger or provider, e.g.
        var logProvider = new TestCaptureLoggerProvider();

        // Act: Perform the action that creates the log entries

        // Assert: Test the results
        _output.WriteLogs(logProvider.GetAllLogEntries())
    }
}

Variants