shlomiassaf / SpecFlow.DependencyInjection

SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpecFlow.DependencyInjection

GitHub License GitHub Issues Azure Build NuGet Package

SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.

Currently supports:

Based on SpecFlow.Autofac. Listed on Available Plugins for SpecFlow.

Usage

Install plugin from NuGet into your SpecFlow project.

PM> Install-Package SolidToken.SpecFlow.DependencyInjection

Create a static method in your SpecFlow project that returns a Microsoft.Extensions.DependencyInjection.IServiceCollection and tag it with the [ScenarioDependencies] attribute. Configure your test dependencies for the scenario execution within this method. Step definition classes (i.e. classes with the SpecFlow [Binding] attribute) are automatically added to the service collection.

A typical dependency builder method looks like this:

[ScenarioDependencies]
public static IServiceCollection CreateServices()
{
    var services = new ServiceCollection();
    
    // TODO: add your test dependencies here

    return services;
}

Refer to SpecFlow.DependencyInjection.Tests for an example.

About

SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C# 92.3%Language:Gherkin 7.7%