Skip to content

Commit

Permalink
route logs to correct test output helper for the older confluence kaf…
Browse files Browse the repository at this point in the history
…ka tests
  • Loading branch information
Fredrik Arvidsson committed Feb 4, 2022
1 parent 3fa8059 commit 01dfe11
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/Confluent.Kafka.1.1.0.Tests/TestSpecificationAsync.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,6 +11,8 @@ namespace Kafka.TestFramework.Tests
{
public class TestSpecificationAsync : XUnit2SpecificationAsync
{
private readonly IDisposable _logWriter;

static TestSpecificationAsync()
{
var config = new ConfigurationBuilder()
Expand All @@ -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();
}
}
}

0 comments on commit 01dfe11

Please sign in to comment.