xUnit¶
SpecFlow supports xUnit 2.4 or later.
Documentation for xUnit can be found here.
Needed NuGet Packages¶
For SpecFlow: SpecFlow.xUnit
For xUnit: xUnit
For Test Discovery & Execution:
Access ITestOutputHelper¶
The xUnit ITestOutputHelper is registered in the ScenarioContainer. You can get access to simply via getting it via Context-Injection.
Example¶
using System;
using TechTalk.SpecFlow;
[Binding]
public class BindingClass
{
private Xunit.Abstractions.ITestOutputHelper _testOutputHelper;
public BindingClass(Xunit.Abstractions.ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}
[When(@"I do something")]
public void WhenIDoSomething()
{
_testOutputHelper.WriteLine("EB7C1291-2C44-417F-ABB7-A5154843BC7B");
}
}