Skip to content

Commit 0303dc9

Browse files
committed
Avoid logging to stale ITestOutputHelper in fixture disposal
1 parent 3f6b34b commit 0303dc9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/ModelContextProtocol.Tests/SseServerIntegrationTestFixture.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
1111
{
1212
private readonly Task _serverTask;
1313
private readonly CancellationTokenSource _stopCts = new();
14-
private DelegatingTestOutputHelper _delegatingTestOutputHelper = new();
1514

16-
private ILoggerFactory _redirectingLoggerFactory;
15+
private readonly DelegatingTestOutputHelper _delegatingTestOutputHelper = new();
16+
private readonly ILoggerFactory _redirectingLoggerFactory;
1717

1818
public McpClientOptions DefaultOptions { get; }
1919
public McpServerConfig DefaultConfig { get; }
@@ -50,6 +50,7 @@ public void Initialize(ITestOutputHelper output)
5050

5151
public async ValueTask DisposeAsync()
5252
{
53+
_delegatingTestOutputHelper.CurrentTestOutputHelper = null;
5354
_redirectingLoggerFactory.Dispose();
5455
_stopCts.Cancel();
5556
try

0 commit comments

Comments
 (0)