-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Xunit console output #644
Conversation
darrencauthon
commented
Jun 12, 2016
•
edited
Loading
edited
…hout changing the instance in the container.
I still need to get this class added into the generated test class: public class XUnitTraceListener : TechTalk.SpecFlow.Tracing.ITraceListener
{
private readonly Xunit.Abstractions.ITestOutputHelper testOutputHelper;
public XUnitTraceListener(Xunit.Abstractions.ITestOutputHelper testOutputHelper)
{
this.testOutputHelper = testOutputHelper;
}
public void WriteTestOutput(string message)
{
testOutputHelper.WriteLine(message);
}
public void WriteToolOutput(string message)
{
testOutputHelper.WriteLine(message);
}
}
I also need this code added to the constructor, adding the block of code above or below the TestInitialize call. public SpecFlowFeature1Feature(ITestOutputHelper testOutputHelper)
{
// starting here =>
var traceListener = (TechTalk.SpecFlow.TestRunnerManager.GetTestRunnerManager()
.GetType()
.GetProperties().Where(x => x.Name == "GlobalContainer")
.Select(x => x.GetValue(TechTalk.SpecFlow.TestRunnerManager.GetTestRunnerManager()))
.FirstOrDefault()
as IObjectContainer)
.Resolve<ITraceListener>() as DefaultListener;
if (traceListener != null)
{
var xUnitTraceListener = new XUnitTraceListener(testOutputHelper);
traceListener.OverrideWith(xUnitTraceListener);
}
/// ^^^^
this.TestInitialize();
}
|
Taking another look at this... I don't think it's going to work the way it is. We can't really touch the global container, I think... at least not with regards to a single instance of I think it would make more sense to load the Still thinking about this... |
This is similar to NUnit3, or? As far as I unterstood XUnit, we have to get the Xunit.Abstractions.ITestOutputHelper by constructor injection on the test class. The ITraceListener ist currently register in the global and the test thread container. In SpecFlow+Runner I am registering it also in the ScenarioContainer. So that would work. |
@SabotageAndi No, I didn't do anything to do with test output for NUnit 3 ... |
closed because of being outdated |