Skip to content

feat(xunit logging): TestOutputHelperWireMockLogger#1488

Merged
StefH merged 2 commits into
wiremock:masterfrom
Stepami:feature/xunit-factory
Jul 17, 2026
Merged

feat(xunit logging): TestOutputHelperWireMockLogger#1488
StefH merged 2 commits into
wiremock:masterfrom
Stepami:feature/xunit-factory

Conversation

@Stepami

@Stepami Stepami commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Current implementation of the TestOutputHelperWireMockLogger obligates me to always have ready-to-use not null instance of ITestOutputHelper. It makes it quite uncomfortable to provide logging in cases when the WireMockServer is wrapped up in a xUnit fixture.

This PR extends applications of the TestOutputHelperWireMockLogger by allowing it to be constructed with Func<ITestOutputHelper>

Use Case

public class WireMockFixture
{
    public WireMockFixture()
    {
        WireMockServer = WireMockServer.Start(
            new WireMockServerSettings
            {
                Logger = new TestOutputHelperWireMockLogger(() => TestOutputHelper)
            });
    }

    public WireMockServer WireMockServer { get; }

    public void Dispose()
    {
        WireMockServer.Dispose();
        TestOutputHelper = null;
    }

    public ITestOutputHelper? TestOutputHelper { get; set; }
}

[CollectionDefinition(nameof(WireMockCollection))]
public class WireMockCollection : ICollectionFixture<WireMockFixture>;

[Collection(nameof(WireMockCollection))]
public class Tests
{
    public Tests(WireMockFixture fixture, ITestOutputHelper testOutputHelper)
    {
        fixture.TestOutputHelper = testOutputHelper;
    }
}

Минин Степан Александрович added 2 commits July 16, 2026 10:47
allow to provide current test output helper
made factory return nullable
@StefH StefH added the feature label Jul 17, 2026
@StefH
StefH merged commit d270ad7 into wiremock:master Jul 17, 2026
7 checks passed
This was referenced Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants