From 01dfe1171cd1e1623bf59f65554c712240128d6c Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Fri, 4 Feb 2022 19:40:28 +0100 Subject: [PATCH] route logs to correct test output helper for the older confluence kafka tests --- .../TestSpecificationAsync.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/Confluent.Kafka.1.1.0.Tests/TestSpecificationAsync.cs b/tests/Confluent.Kafka.1.1.0.Tests/TestSpecificationAsync.cs index 22adb82..4096dad 100644 --- a/tests/Confluent.Kafka.1.1.0.Tests/TestSpecificationAsync.cs +++ b/tests/Confluent.Kafka.1.1.0.Tests/TestSpecificationAsync.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Log.It; using Log.It.With.NLog; using Microsoft.Extensions.Configuration; @@ -10,6 +11,8 @@ namespace Kafka.TestFramework.Tests { public class TestSpecificationAsync : XUnit2SpecificationAsync { + private readonly IDisposable _logWriter; + static TestSpecificationAsync() { var config = new ConfigurationBuilder() @@ -19,23 +22,18 @@ 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; - } - - protected virtual Task TearDownAsync() - { - return Task.CompletedTask; + _logWriter = Output.WriteTo(testOutputHelper); } 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