Class UseTinyBddAttribute
Instructs NUnit to register AmbientTestMethodResolver and track the currently executing test method for TinyBDD.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)]
public sealed class UseTinyBddAttribute : NUnitAttribute, ITestAction
- Inheritance
-
NUnitAttributeUseTinyBddAttribute
- Implements
-
ITestAction
- Inherited Members
Examples
[TestFixture]
[UseTinyBdd]
public class CalculatorTests
{
[Test]
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 NUnit’s NUnit.Framework.Interfaces.ITest metadata. After the test finishes, it clears the ambient method reference.
This makes CreateContext(object, string?, ITraitBridge?, ScenarioOptions?) capable of resolving the correct test method without relying on stack walking.
Properties
Targets
Indicates that this attribute applies to tests and test cases.
public ActionTargets Targets { get; }
Property Value
- ActionTargets
Methods
AfterTest(ITest)
Executed after each test is run
public void AfterTest(ITest test)
Parameters
testITestThe test that has just been run.
BeforeTest(ITest)
Executed before each test is run
public void BeforeTest(ITest test)
Parameters
testITestThe test that is going to be run.