Class UseTinyBddAttribute
Instructs xUnit to register AmbientTestMethodResolver and track the currently executing test method for TinyBDD.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)]
public sealed class UseTinyBddAttribute : BeforeAfterTestAttribute
- Inheritance
-
BeforeAfterTestAttributeUseTinyBddAttribute
- Inherited Members
Examples
[UseTinyBdd]
public class CalculatorTests
{
[Fact]
public async Task AddsNumbers()
{
await Flow.Given(() => 1)
.When("add", x => x + 1)
.Then("== 2", v => v == 2);
}
}
Remarks
This attribute can be applied at the class or method level. Before each test executes, it calls Register(ITestMethodResolver) with the global Instance and sets the current MethodInfo from xUnit’s test pipeline. After the test finishes, it clears the ambient method reference.
This allows CreateContext(object, string?, ITraitBridge?, ScenarioOptions?) to resolve the correct test method reliably even in async scenarios.
Methods
After(MethodInfo)
This method is called after the test method is executed.
public override void After(MethodInfo methodUnderTest)
Parameters
methodUnderTestMethodInfoThe method under test
Before(MethodInfo)
This method is called before the test method is executed.
public override void Before(MethodInfo methodUnderTest)
Parameters
methodUnderTestMethodInfoThe method under test