diff --git a/tests/Kafka.TestFramework.Tests/TestSpecificationAsync.cs b/tests/Kafka.TestFramework.Tests/TestSpecificationAsync.cs index 3cacb38..903c6c1 100644 --- a/tests/Kafka.TestFramework.Tests/TestSpecificationAsync.cs +++ b/tests/Kafka.TestFramework.Tests/TestSpecificationAsync.cs @@ -12,6 +12,8 @@ namespace Kafka.TestFramework.Tests { public class TestSpecificationAsync : XUnit2SpecificationAsync { + private readonly IDisposable _logWriter; + static TestSpecificationAsync() { var config = new ConfigurationBuilder() @@ -21,26 +23,21 @@ static TestSpecificationAsync() NLog.LogManager.Configuration = new NLogLoggingConfiguration(config.GetSection("NLog")); LogFactory.Initialize(new NLogFactory(new LogicalThreadContext())); + NLogCapturingTarget.Subscribe += Output.Writer.WriteLine; } public TestSpecificationAsync(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { - NLogCapturingTarget.Subscribe += TestOutputHelper.WriteLine; + _logWriter = Output.WriteTo(testOutputHelper); } protected CancellationToken TimeoutCancellationToken => new CancellationTokenSource(TimeSpan.FromSeconds(20)).Token; - protected virtual Task TearDownAsync() - { - return Task.CompletedTask; - } - protected sealed override async Task DisposeAsync(bool disposing) { - NLogCapturingTarget.Subscribe -= TestOutputHelper.WriteLine; - await TearDownAsync(); await base.DisposeAsync(disposing); + _logWriter.Dispose(); } } } \ No newline at end of file