-
Notifications
You must be signed in to change notification settings - Fork 0
IBeforeStep
Romfos edited this page Feb 26, 2026
·
2 revisions
You can use IBeforeStep for create custom logic that will be executed before each step:
namespace BddDotNet.Steps;
public interface IBeforeStep
{
Task BeforeStepAsync(StepContext context);
}- Create class with custom logic
internal sealed class MyBeforeStep : IBeforeStep
{
public async Task BeforeStepAsync(StepContext context)
{
Console.WriteLine($"MyBeforeStep {context.Type}, {context.Text}");
}
}- Register it in
Program.cspipeline viaBeforeStepextension method onIServiceCollection
using BddDotNet;
using BddDotNet.Steps;
using Microsoft.Testing.Platform.Builder;
var builder = await TestApplication.CreateBuilderAsync(args);
var services = builder.AddBddDotNet();
services.BeforeStep<MyBeforeStep>();
services.SourceGeneratedGherkinScenarios();
services.SourceGeneratedGherkinSteps();
using var testApp = await builder.BuildAsync();
return await testApp.RunAsync();Result:
Setup
BddDotNet
Extensibility
Gherkin