-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathNUnitTraceListener.cs
37 lines (30 loc) · 1.21 KB
/
NUnitTraceListener.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using Reqnroll.BoDi;
using NUnit.Framework;
using Reqnroll.Infrastructure;
using Reqnroll.Tracing;
namespace Reqnroll.NUnit.ReqnrollPlugin
{
public class NUnitTraceListener : AsyncTraceListener
{
private readonly Lazy<IContextManager> _contextManager;
public NUnitTraceListener(ITraceListenerQueue traceListenerQueue, IObjectContainer container) : base(traceListenerQueue, container)
{
_contextManager = new Lazy<IContextManager>(container.Resolve<IContextManager>);
}
public override void WriteTestOutput(string message)
{
TestContext.WriteLine(message);
// avoid duplicate output entries in NUnit for scenario, forward only if no scenario active
if (_contextManager.Value.ScenarioContext == null)
base.WriteTestOutput(message);
}
public override void WriteToolOutput(string message)
{
TestContext.WriteLine("-> " + message);
// avoid duplicate output entries in NUnit for scenario, forward only if no scenario active
if (_contextManager.Value.ScenarioContext == null)
base.WriteToolOutput(message);
}
}
}