Class ScenarioOutlineBuilder<TExample>
- Namespace
- TinyBDD
- Assembly
- TinyBDD.dll
Represents a Gherkin-style scenario outline that can be executed with multiple example rows.
public sealed class ScenarioOutlineBuilder<TExample>
Type Parameters
TExampleThe type of example data.
- Inheritance
-
ScenarioOutlineBuilder<TExample>
- Inherited Members
Examples
await Bdd.ScenarioOutline<(int a, int b, int expected)>(ctx, "Addition")
.Given("first number", ex => ex.a)
.And("second number", (_, ex) => ex.b)
.When("added", (a, b) => a + b)
.Then("result matches expected", (sum, ex) => sum == ex.expected)
.Examples(
(a: 1, b: 2, expected: 3),
(a: 5, b: 5, expected: 10))
.AssertAllPassedAsync();
Remarks
A scenario outline is a template for scenarios that allows you to run the same steps with different data values. Each step receives both the current chain value and the example data, enabling data-driven testing with a fluent API.
Methods
Given<T>(string, Func<TExample, Task<T>>)
Starts the scenario outline with a Given step that uses example data asynchronously.
public ScenarioOutlineChain<TExample, T> Given<T>(string title, Func<TExample, Task<T>> setup)
Parameters
titlestringThe step title.
setupFunc<TExample, Task<T>>An async function that receives the example and returns the initial value.
Returns
- ScenarioOutlineChain<TExample, T>
A chain builder for continuing the scenario outline.
Type Parameters
TThe type produced by the setup.
Given<T>(string, Func<TExample, T>)
Starts the scenario outline with a Given step that uses example data.
public ScenarioOutlineChain<TExample, T> Given<T>(string title, Func<TExample, T> setup)
Parameters
titlestringThe step title.
setupFunc<TExample, T>A function that receives the example and returns the initial value.
Returns
- ScenarioOutlineChain<TExample, T>
A chain builder for continuing the scenario outline.
Type Parameters
TThe type produced by the setup.