Class TinyBddOptionsBuilder
- Namespace
- TinyBDD
- Assembly
- TinyBDD.dll
Fluent builder for configuring TinyBDD with observers, output options, and extensibility features.
public sealed class TinyBddOptionsBuilder
- Inheritance
-
TinyBddOptionsBuilder
- Inherited Members
Examples
var options = TinyBdd.Configure(builder => builder
.AddObserver(new LoggingObserver())
.AddObserver(new TelemetryObserver()));
await TinyBddScenario.With(options)
.Given("start", () => 1)
.When("add", x => x + 1)
.Then("is 2", x => x == 2)
.AssertPassed();
Remarks
This builder provides an EF Core-style fluent API for adding cross-cutting functionality to TinyBDD scenarios via observers and service registration. Extensions like structured logging, OpenTelemetry, and JSON reporting are added through methods on this builder.
The builder is typically used via TinyBdd.Configure for standalone scenarios, or injected into test adapter base classes for framework integration.
Methods
AddObserver(IScenarioObserver)
Adds a scenario-level observer to the pipeline.
public TinyBddOptionsBuilder AddObserver(IScenarioObserver observer)
Parameters
observerIScenarioObserverThe observer to add.
Returns
- TinyBddOptionsBuilder
This builder for fluent chaining.
Remarks
Observers are invoked in the order they are added. Multiple observers of the same type can be registered.
AddObserver(IStepObserver)
Adds a step-level observer to the pipeline.
public TinyBddOptionsBuilder AddObserver(IStepObserver observer)
Parameters
observerIStepObserverThe observer to add.
Returns
- TinyBddOptionsBuilder
This builder for fluent chaining.
Remarks
Observers are invoked in the order they are added. Multiple observers of the same type can be registered.
ConfigureServices(Action<IServiceCollection>)
Configures services available to extensions and observers using Microsoft's IServiceCollection.
public TinyBddOptionsBuilder ConfigureServices(Action<IServiceCollection> configure)
Parameters
configureAction<IServiceCollection>An action that configures the service collection.
Returns
- TinyBddOptionsBuilder
This builder for fluent chaining.
Remarks
This uses Microsoft.Extensions.DependencyInjection for service registration, providing first-class DI features while maintaining flexibility for standalone scenarios.