Class UseTinyBddAttribute
Instructs xUnit.v3 to register AmbientTestMethodResolver and track the currently executing test method for TinyBDD.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)]
public sealed class UseTinyBddAttribute : BeforeAfterTestAttribute, IBeforeAfterTestAttribute
- Inheritance
-
BeforeAfterTestAttributeUseTinyBddAttribute
- Implements
-
IBeforeAfterTestAttribute
- 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, IXunitTest)
This method is called after the test method is executed.
public override void After(MethodInfo methodUnderTest, IXunitTest test)
Parameters
methodUnderTestMethodInfoThe method under test
testIXunitTestThe current Xunit.Sdk.ITest
Before(MethodInfo, IXunitTest)
This method is called before the test method is executed.
public override void Before(MethodInfo methodUnderTest, IXunitTest test)
Parameters
methodUnderTestMethodInfoThe method under test
testIXunitTestThe current Xunit.Sdk.ITest