Skip to content

Commit 01dfe11

Browse files
author
Fredrik Arvidsson
committedFeb 4, 2022
route logs to correct test output helper for the older confluence kafka tests
1 parent 3fa8059 commit 01dfe11

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System;
2+
using System.Threading.Tasks;
23
using Log.It;
34
using Log.It.With.NLog;
45
using Microsoft.Extensions.Configuration;
@@ -10,6 +11,8 @@ namespace Kafka.TestFramework.Tests
1011
{
1112
public class TestSpecificationAsync : XUnit2SpecificationAsync
1213
{
14+
private readonly IDisposable _logWriter;
15+
1316
static TestSpecificationAsync()
1417
{
1518
var config = new ConfigurationBuilder()
@@ -19,23 +22,18 @@ static TestSpecificationAsync()
1922

2023
NLog.LogManager.Configuration = new NLogLoggingConfiguration(config.GetSection("NLog"));
2124
LogFactory.Initialize(new NLogFactory(new LogicalThreadContext()));
25+
NLogCapturingTarget.Subscribe += Output.Writer.WriteLine;
2226
}
2327

2428
public TestSpecificationAsync(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
2529
{
26-
NLogCapturingTarget.Subscribe += TestOutputHelper.WriteLine;
27-
}
28-
29-
protected virtual Task TearDownAsync()
30-
{
31-
return Task.CompletedTask;
30+
_logWriter = Output.WriteTo(testOutputHelper);
3231
}
3332

3433
protected sealed override async Task DisposeAsync(bool disposing)
3534
{
36-
NLogCapturingTarget.Subscribe -= TestOutputHelper.WriteLine;
37-
await TearDownAsync();
3835
await base.DisposeAsync(disposing);
36+
_logWriter.Dispose();
3937
}
4038
}
4139
}

0 commit comments

Comments
 (0)
Please sign in to comment.