Skip to content

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

License

Notifications You must be signed in to change notification settings

shlomiassaf/SpecFlow.DependencyInjection

 
 

Repository files navigation

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 92.3%
  • Gherkin 7.7%