Stravaig Logging Diagnostics

Diagnostics for examining logs in automated tests.

XUnit Extensions

Support for xunit v2 is available from v2.1 onwards in package Stravaig.Extensions.Logging.Diagnostics.XUnit

Support for xunit v3 is available from v4.1 onwards in package Stravaig.Extensions.Logging.Diagnostics.XUnit.v3

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