Table of Contents

Class UseTinyBddAttribute

Namespace
TinyBDD.Xunit
Assembly
TinyBDD.Xunit.dll

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
BeforeAfterTestAttribute
UseTinyBddAttribute
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

methodUnderTest MethodInfo

The method under test

Before(MethodInfo)

This method is called before the test method is executed.

public override void Before(MethodInfo methodUnderTest)

Parameters

methodUnderTest MethodInfo

The method under test

See Also