GithubHelp home page GithubHelp logo

solidtoken / specflow.dependencyinjection Goto Github PK

View Code? Open in Web Editor NEW
35.0 5.0 11.0 81 KB

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

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

Gherkin 9.20% C# 90.80%
microsoft dependencyinjection di specflow plugin nuget

specflow.dependencyinjection's Introduction

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 (in preview):

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.

specflow.dependencyinjection's People

Contributors

304notmodified avatar connorchristie avatar dependabot[bot] avatar ivanalekseev avatar mbhoek avatar shlomiassaf avatar vakarisl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

specflow.dependencyinjection's Issues

Request: Support for Microsoft.Extensions.DependencyInjection <= Version 3.1.18

Hi,

Thanks for creating this nuget package. My .net core 3.1 project is currently using Microsoft.Extensions.DependencyInjection Version 3.1.17. Is it possible for this nuget package to support lower versions?

When I downloaded the code and changed the line below, the tests still pass.

<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.18" />

I've not tried it in anger with my existing solution however.

It's not really a big issue, as I should update my projects, as Microsoft.Extensions.DependencyInjection 5+ is compatible with .net core 3.1.

Scoping Context Injection to Scenario Execution Lifetimes

The default Context Injection in SpecFlow is scoped to the life-time of scenario execution, how do we go about achieving this with SpecFlow.DependencyInjection?

As steps are global across the entire project, I have separated the steps into logical units/binding classes where a single scenario may invoke steps from multiple bindings. This means I need to share the same context instance between each. Right now I'm having trouble because each binding class is receiving its own context instance. Adding the context instances as singletons won't help either.

Align .NET version support with SpecFlow 3.3

SpecFlow announced in May it will support .NET Framework >= 4.6.1, .NET Core 2.1 and .NET 3.1 starting with SpecFlow 3.3 (SpecFlowOSS/SpecFlow/issues/1982). Also see: https://specflow.org/blog/we-are-simplifying-our-specflow-and-net-version-support/

It makes sense to align SpecFlow.DependencyInjection; therefore, the library:

  • must target .NET Standard 2.0
  • must support .NET 5
  • should support .NET Core LTS versions
  • should support .NET Framework 4.8
  • must support .NET Framework >= 4.6.1

After ScenarioContext class is used in steps, disposal fails.

If steps are using ScenarioContext for context injection as described in SpecFlow documentation, i.e.:

[Binding]
public class ContextInjectionScopeSteps
{
    private readonly ScenarioContext _context;

    public ContextInjectionScopeSteps(ScenarioContext context)
    {
        _context = context;
    }

    [Given(@"I have test context with number (.*)")]
    public void GivenIHaveTestContextWithNumber(int number)
    {
        _context["number"] = number;
        //or
        //_context.Set(number);
    }
}

then on cleanup test fails with System.InvalidOperationException : Collection was modified; enumeration operation may not execute.:
image

Support .NET 6

As a maintainer, I want to ensure .NET 6 is supported (and older versions are deprecated as per .NET Support Policy).

Also do a better job at supporting (and testing) older versions if possible (see #67).

Also review (and where applicable implement) NuGet 6.0 changes.

Consider adding #65 as well.

Add Package Validation

"Package Validation tooling will allow library developers to validate that their packages are consistent and well-formed. It involves validating that there are no breaking changes across versions. It will validate that the package have the same set of publics APIs for all the different runtime-specific implementations. It will also help developers to catch any applicability holes."
https://devblogs.microsoft.com/dotnet/package-validation/

Support for asynchronous creation of service collection

Hi!

I want to use Microsoft.Extensions.DependencyInjection in our e2e tests to make use of Microsoft's native stuff like .AddLogging() and follow the same practices we use in our web app codebase.

We also use Playwright in our project, so we need a way to register it as well to the DI container. I know that the container itself does not support async registration, but I was wondering if the creation of the ServiceCollection could support async?

The way this works with the default BoDi container is like this:

[Binding]
public class PlaywrightHooks
{
    private readonly IObjectContainer _objectContainer;

    public PlaywrightHooks(IObjectContainer objectContainer) => _objectContainer = objectContainer;

    [BeforeScenario]
    public async Task RegisterPlaywright()
    {
        var playwright = await Playwright.CreateAsync();
        _objectContainer.RegisterInstanceAs(playwright);

        // Other registrations
        // ..
    }
}

So I guess a simple way how this would look like in this package is something like this:

public static class Startup
{
    [ScenarioDependencies]
    public static async Task<IServiceCollection> CreateServicesAsync()
    {
        var services = new ServiceCollection();

        var playwright = await Playwright.CreateAsync();
        services.AddSingleton(playwright);

        // Other registrations
        // ..

        return services;
    }
}

Would this be something your package could support?

Use GitHub Actions for CI/CD

As a developer, I want to move to GitHub Actions in order to:

  • be more open about the process
  • get experience with GitHub Actions
  • don't have a dependency on a private resource

Requires:

  • access to (the) GitHub Actions (beta)
  • checkout the documentation
  • testing (and thus CI/CD) in a different branch than master
  • use GitHub Releases (in the same way as SpecFlow; first publish Nuget, then release)
  • add Symbol Packages to NuGet server (follow-up of #21)
  • nuget package asset is missing from the GitHub Release (sometimes)
  • automatically generate release notes

Scoped container dispose issue

Hi!

Faced with an issue when scenario and feature containers were disposed too early in execution context.

You are handling RuntimePluginTestExecutionLifecycleEvents.AfterScenario and RuntimePluginTestExecutionLifecycleEvents.AfterFeature events to dispose scoped container. There are additional functionality after that events still in scope of scenario and feature.

Is it possible to postpone scoped DI dispose operations?

SourceLink is not working as expected

As a developer (consumer), I expect SourceLink to work. This means that if I use SpecFlow.DepencyInjection, I want to be able to step into the source code as part of the debugging experience.

It appears that SourceLink is not working because the .pdb file cannot be found.
It appears that .pdb file cannot be found because of a 'new build system' where .NET no longer copies the .pdb file from the NuGet package, but only the .dll file.
I've confirmed that if you manually select the .pdb file, you will get SourceLink support; so the main bug seems to be that the .pdb file is no longer copied from the NuGet package.

Proposed solutions are to either embed the .pdb into the .dll file, or setup a separate Symbol Package (also involves additional settings in Visual Studio). Preferred approach appears to be Symbol Packages; see https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg

CI build fails after merge to master

After merging PR #17 into master, the automated CI build failed.

error CS0246: The type or namespace name 'SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\SpecFlow.DependencyInjection.Tests\SpecFlow.DependencyInjection.Tests.csproj]

However, on the same master branch a manual build succeeds.
The pull request build also succeeded.

Is this a repeatable bug? What causes it? Is it solved by moving to GitHub Actions (#11)?

AddHttpMessageHandler throwing an exception

I was trying to register httpclient and attach a message handler to it. Here is a sample:

services.AddHttpClient("namedClient", client =>{
    client.BaseAddress = "baseAddress";
}).AddHttpMessageHandler<AuthenticationHandler>();

My authentication handler needs a TokenProviderFactory instance so the registration additionally adds

services.AddScoped<TokenProviderFactory>();

and constructor looks like:

public class AuthenticationHandler : DelegatingHandler
{
    private readonly TokenProviderFactory _tokenProviderFactory;
    public AuthenticationHandler(TokenProviderFactory tokenProviderFactory)
    {
        _tokenProviderFactory = tokenProviderFactory;
    }
    
    //additional implementation
}

Later on, I need ScenarioContext (or custom-created Scoped Context) to be injected into TokenProviderFactory

public class TokenProviderFactory
{
    private readonly ScenarioContext _scenarioContext;
    private readonly Identity _identity;

    public TokenProviderFactory(ScenarioContext scenarioContext,
        Identity identity)
    {
        _scenarioContext = scenarioContext;
        _identity = identity;
    }

    //additional implementation
}

And here is the problem. When I try to create httpClient using httpClientFactory in my steps definitions, I'm not able because I'm not able to resolve ScenarioContext used in TokenProviderFactory. The exception is thrown from here:

services.AddTransient(sp => BindMappings[sp].ScenarioContext);

And it is thrown because the Service Provider which is used in DependencyInjectionPlugin class is not the same as the one used for attaching message handlers. Here is the Microsoft implementation of AddHttpMessageHandler extension method.

public static IHttpClientBuilder AddHttpMessageHandler(this IHttpClientBuilder builder, Func<DelegatingHandler> configureHandler)
{
    //some checks
    builder.Services.Configure<HttpClientFactoryOptions>(builder.Name, options =>
    {
        options.HttpMessageHandlerBuilderActions.Add(b => b.AdditionalHandlers.Add(configureHandler()));
    });
    return builder;
}

Any recommendations on how to solve the issue?

Support .NET Core LTS

As a developer, I want to support all .NET Core LTS versions.

The .NET Core official support policy lists 2.1 (SDK 2.1.803) and 3.1 (SDK 3.1.101) as the current LTS versions (2020-02-15).

  • ensure that SpecFlow.DependencyInjection supports both 2.1 and 3.1 LTS versions
  • investigate whether to support netstandard2.0, netstandard2.1, or both
  • confirm that correct SpecFlow version is referenced in all cases
  • check if referencing Microsoft.Extensions.DependencyInjection.Abstractions is enough

The package SpecFlow.DependencyInjection must target netstandard2.0.

[ScenarioDependencies] replaces DI implementation of the framework or the library(s)

Background

I want to inject the dependencies for the scenarios. To do this I have followed the code from the README and I performed the equivalent implementation, see implementation section:

Along with dependencies that I inject manually using the [ScenarioDependencies] attribute, I also wanted to have other dependencies like specFlowOutputHelperHelper available in the constructor as well; which are injected by the framework automatically in the background.

Implementation

My implementation logic is as follows:

class Hook
{
  . . .
  [ScenarioDependencies]
  public static IServiceCollection CreateServices()
  {
    var services = new ServiceCollection();
    services.AddScoped<MyDependency>();
    return services;
  }
  . . .
}


class StepDefinition
{
  . . .
  public StepDefinition(MyDependency myDependency, 
        ISpecFlowOutputHelper specFlowOutputHelperHelper, ScenarioContext scenarioContext
        )
  {
     . . .
  }
  . . .
}

Problem

The mechanism implemented in [ScenarioDependencies] somehow replaces a part of the DI implementation (auto-injection of dependencies) of the framework or the other library(s). For instance, I can no longer get an instance of SpecFlowOutputHelper class automatically in the constructor, within the binding step definition class i.e. StepDefinition. I get following error:

System.InvalidOperationException : Unable to resolve service for type 'TechTalk.SpecFlow.Infrastructure.ISpecFlowOutputHelper' while attempting to act...

To get the instances of these classes, I have to manually inject their objects.

Question

How can we preserve the DI implementation of the framework or the library(s)?

Fix multiple matches in Coverage Report

The CI - Build - Report step in Azure Pipelines generates a coverage report using Cobertura. It results in the following warning:

##[warning]Multiple file or directory matches were found. Using the first match: /home/vsts/work/_temp/1e60b86f-67cf-479b-a83d-f2e9d591771c/coverage.cobertura.xml

Example: https://dev.azure.com/SolidToken/GitHub/_build/results?buildId=678&view=logs&j=2831d33e-84dd-5533-eda0-8105954f1bc8&t=4bbd8bc0-4fe5-5c09-ca54-750bd219b7c9&l=9

Evaluate [FeatureDependencies]

The Autofac plugin recently introduced the [FeatureDependencies] attribute (SpecFlowOSS/SpecFlow#2622).
Evaluate whether it makes sense to add this to this plugin as well.

Personally I think it makes sense to keep the way this plugin works in line with the 'main' Autofac one.

MissingMethodException on SpecFlow 3.7.13

When I want to use this package with SpecFlow 3.7.13 there would a problem regarding finding a method in BoDi.
There're not any problems with previous version of Specflow because they use BoDi 1.4.1 but SpecFlow 3.7.13 use BoDi 1.15.

  Message: 
    System.AggregateException : One or more errors occurred. (Method not found: 'Void BoDi.ObjectContainer.RegisterTypeAs(System.String)'.) (Method not found: 'Void BoDi.ObjectContainer.RegisterTypeAs(System.String)'.) (The following constructor parameters did not have matching fixture data: FixtureData fixtureData, SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture assemblyFixture)
    ---- System.MissingMethodException : Method not found: 'Void BoDi.ObjectContainer.RegisterTypeAs(System.String)'.
    ---- System.MissingMethodException : Method not found: 'Void BoDi.ObjectContainer.RegisterTypeAs(System.String)'.
    ---- The following constructor parameters did not have matching fixture data: FixtureData fixtureData, SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture assemblyFixture
  Stack Trace: 
    ----- Inner Stack Trace #1 (System.MissingMethodException) -----
    DependencyInjectionPlugin.<Initialize>b__1_0(Object sender, CustomizeGlobalDependenciesEventArgs args)
    RuntimePluginEvents.RaiseCustomizeGlobalDependencies(ObjectContainer container, SpecFlowConfiguration specFlowConfiguration)
    ContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider)
    TestRunnerManager.CreateTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder)
    TestRunnerManager.GetTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder, Boolean createIfMissing)
    TestRunnerManager.OnTestRunStart(Assembly testAssembly, IContainerBuilder containerBuilder)
    SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture.ctor() line 19
    ----- Inner Stack Trace #2 (System.MissingMethodException) -----
    DependencyInjectionPlugin.<Initialize>b__1_0(Object sender, CustomizeGlobalDependenciesEventArgs args)
    RuntimePluginEvents.RaiseCustomizeGlobalDependencies(ObjectContainer container, SpecFlowConfiguration specFlowConfiguration)
    ContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider)
    TestRunnerManager.CreateTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder)
    TestRunnerManager.GetTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder, Boolean createIfMissing)
    TestRunnerManager.GetTestRunner(Assembly testAssembly, Nullable`1 managedThreadId, IContainerBuilder containerBuilder)
    ContextInjectionScopeFeature.FeatureSetup()
    FixtureData.ctor()
    ----- Inner Stack Trace #3 (Xunit.Sdk.TestClassException) -----

cc @mbhoek

System.NullReferenceException inside TechTalk.SpecFlow

Hi,

I added this to my specflow project:

    <PackageReference Include="SpecFlow" Version="3.1.80" />
    <PackageReference Include="SpecFlow.MsTest" Version="3.1.80" />
    <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.80" />
    <PackageReference Include="SolidToken.SpecFlow.DependencyInjection" Version="0.3.2" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
    <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />

and

	public class SpecflowHooks
	{
		
		[ScenarioDependencies]
		public static IServiceCollection CreateServices()
		{
			var services = new ServiceCollection();
			return services;
		}
	}

And now I get for all tests:

System.NullReferenceException: Object reference not set to an instance of an object.
    at lambda_method(Closure , IContextManager , String )
   at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) in D:\a\1\s\TechTalk.SpecFlow\Bindings\BindingInvoker.cs:line 69
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 501
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 422
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.Step(StepDefinitionKeyword stepDefinitionKeyword, String keyword, String text, String multilineTextArg, Table tableArg) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 581
   at TechTalk.SpecFlow.TestRunner.Given(String text, String multilineTextArg, Table tableArg, String keyword) in D:\a\1\s\TechTalk.SpecFlow\TestRunner.cs:line 80
   at 

any idea?

Update: same issue with 0.3.1 and 0.2.4. What am I missing?

Compatibility with SpecFlow 3.7.13, MsTest and MSDI 5.0.1

I've tried the nuget package in my netcoreapp3.1 project with SpecFlow 3.7.13 and SpecFlow.MsTest and I kept getting

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void BoDi.ObjectContainer.RegisterTypeAs(System.String)'.
  Source=SolidToken.SpecFlow.DependencyInjection.SpecFlowPlugin
  StackTrace:
   at SolidToken.SpecFlow.DependencyInjection.DependencyInjectionPlugin.<Initialize>b__1_0(Object sender, CustomizeGlobalDependenciesEventArgs args) in D:\a\1\s\SpecFlow.DependencyInjection\DependencyInjectionPlugin.cs:line 33
   at TechTalk.SpecFlow.Plugins.RuntimePluginEvents.RaiseCustomizeGlobalDependencies(ObjectContainer container, SpecFlowConfiguration specFlowConfiguration)
   at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider)
   at TechTalk.SpecFlow.MSTest.SpecFlowPlugin.MsTestContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider)
   at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder)
   at TechTalk.SpecFlow.TestRunnerManager.GetTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder, Boolean createIfMissing)
   at TechTalk.SpecFlow.TestRunnerManager.OnTestRunStart(Assembly testAssembly, IContainerBuilder containerBuilder)
   at io_myproject_test_MSTestAssemblyHooks.AssemblyInitialize(TestContext testContext) in D:\source\myproject\myproject\myproject\src\test\obj\Debug\netcoreapp3.1\MSTest.AssemblyHooks.cs:line 22

Spewing out when running the tests. I cloned the repo, upgraded the packages to MSDI 5.01, Specflow, 3.7.13, and in the test project SpecFlow mstest 3.7.13, (i converted the step defs), swtiched xunit to mstest.testadapter and updated microsoft.net.test.sdk fpr 16.9.1, and all the tests pass, and it works in my project.

I'm not sure what to do with that information, other than suggest maybe something has changed between MSDI 3.1.6->5.0.1 and SpecFlow 3.3.0->3.7.13, and a new build might be needed to satisfy whatever it doesn't like above. The MsTest switch in the test projects was really just to make sure I could test and compare against what was breaking my stuff.

Release management

As an owner, I want to document (or even better: automate) the release process.

Currently in place:

  • Squash merge feature branches into master
  • Gitversion calculates SemVer (use +semver: commit message to influence)
  • Azure DevOps Build
    • builds PRs and master
    • tests
    • creates NuGet package
    • publish package as artifact
  • Azure DevOps Release
    • creates a draft GitHub release (needs manual editing)

As an owner, I want a single button to:

  • trigger the release automatically after approval
  • build, test and package the release
  • deploy the package to NuGet.org
    • note that NuGet takes time to verify a release
    • there are additional interesting fields to set, like the Release Notes
  • create a GitHub release
    • only after listed on NuGet.org

Support IAsyncDisposable

If you register a class that implements IAsyncDisposable to the container it would throw following exception:

TearDown : System.InvalidOperationException : 'IntegrationTests.Order' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
--TearDown
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.Dispose()
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.Dispose()
   at BoDi.ObjectContainer.Dispose()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.InternalContextManager`1.DisposeInstance()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.InternalContextManager`1.Cleanup()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.CleanupScenarioContext()
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioEnd()
   at TechTalk.SpecFlow.TestRunner.OnScenarioEnd()
   at GT.Buzzinga.Tests.IntegrationTests.Features.SeedGenerationFeature.TestTearDown()

Package version: 3.7.0 / .NET 5

cc @mbhoek

The type 'ServiceCollection' exists in both 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.Extensions.DependencyInjection, Version=3.1.0.0

I have .net 6 projected and when I install this package and try to create ServiceCollection I get below error

Severity Code Description Project File Line Suppression State
Error CS0433 The type 'ServiceCollection' exists in both 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.Extensions.DependencyInjection, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

Update documentation for v1.0 release

As a maintainer, I want to update all documentation (in the broadest sense) before releasing v1.0.

  • README (review the setup code, make it an 'easy howto')
  • LICENSE (see what the impact of the new SpecFlow license is)
  • NuGet package description (see SpecFlow NuGet package)
  • Complete community profile
  • Source code (and examples?)
  • Document the main exception (Unable to find scenario dependencies! Mark a static method that returns a IServiceCollection with [ScenarioDependencies]!)

Automatically register SpecFlow bindings

Currently the developer has to write a little bit of setup code to setup the DI for SpecFlow (as described in the README.md). This setup code needs to register all the SpecFlow [Binding]s otherwise the SpecFlow tests will fail with a obscure error message.

As a developer, I want to automatically register all [Binding]s in the same Assembly where the [ScenarioDependencies] is defined.

  • Add a AutoRegisterBindings (default True) to [ScenarioDependencies
  • Automatically register the appropriate [Binding]s

Change CD to make pre-releases available

As a devops, I want to have the ability to build 'pre-release' versions of the package.

Currently we always release what is commited to main (adopting the Mainline paradigm of gitversion). This was in line with the expectation that the plugin was stable and only minor changes would be made for each . release of SpecFlow.

However we now wish to rearchitect major parts of the plugin, with several contributions (e.g. #74, #75, #12, #77), so now there is a need to be able to release intermediary version, i.e. 'pre-releases'.

Plan:

  • change gitversion mode to Continuous Delivery
  • change CD so that main get build, signed, pushed to NuGet as pre-release
  • change CD so that 'tags' get build, signed, pushed to NuGet as release
  • NOTE: CD currently actively sets the version tag, this must change to passively reading the tag Correct, GitVersion is source
  • TODO: who will set the tag?
  • Code Signing does not work anymore; fix and document

How to use TestRunContext for inject configuration

There are difference with default SpecFlow Ioc, the method is static and is not possible to inject TestRunContext like the Specflow sample.


    [Binding]
    public class Hooks
    {
        private readonly TestRunContext _testRunContext;
        
        public Hooks(TestRunContext testRunContext)
        {
            _testRunContext = testRunContext;
        }

        [BeforeScenario(Order = 1)]
        public void RegisterDependencies(IObjectContainer objectContainer)
        {
            objectContainer.RegisterInstanceAs(new DatabaseContext());

            IConfiguration config = new ConfigurationBuilder()
                .AddJsonFile(Path.Combine(_testRunContext.TestDirectory, "appsettings.json"), optional: true, reloadOnChange: true)
                .Build();

            objectContainer.RegisterInstanceAs(config);

VS

    public static class ServiceModule
    {
        [ScenarioDependencies]
        public static IServiceCollection CreateServices()
        {
            var services = new ServiceCollection();

There are equivalent please ?

Concurrency issue when using Amazon.Extensions.Configuration.SystemsManager

Getting a concurrency error when trying to use Amazon.Extensions.Configuration.SystemsManager with SpecFlow.DependencyInjection in the [ScenarioDependencies] tagged method

Reproduction

Source

I've created a fork of the project to illustrate the bug here

Specifics

  1. Add the Amazon.Extensions.Configuration.SystemsManager nuget package
  2. Update the [ScenarioDependencies] code to include
[ScenarioDependencies]
public static IServiceCollection CreateServices()
{
    var services = new ServiceCollection();

    // Add test dependencies
    services.AddTransient<ITestService, TestService>();

    // ContextInjectionScope (by using AddScoped instead of AddTransient, the context will be scoped to the Feature across bindings)
    services.AddScoped<TestContext>();

    // Calculator
    services.AddScoped<ICalculator, Calculator>();
    
    // NB: This breaks when parallelizeTestCollections = true (xunit.runner.json)
    //      When debugging, the error does not occur, presumably because the tests are not running in parallel
    var configuration = new ConfigurationBuilder();
    configuration.AddSystemsManager(c =>
    {
        c.Path = "path";
        c.Optional = true;
    });
    configuration.Build();

    return services;
}
  1. Run the tests in parallel (this is the default)
    i. you will receive a Concurrent object resolution timeout (potential circular dependency). error
    ii. if you run any test indivdually, debug all the tests or run with parallelizeTestCollections: false in a xunit.runner.json file the tests will succeed

Full error message

BoDi.ObjectContainerException: Concurrent object resolution timeout (potential circular dependency).

BoDi.ObjectContainerException
Concurrent object resolution timeout (potential circular dependency).
   at BoDi.ObjectContainer.RegistrationWithStrategy.ExecuteWithLock(Object lockObject, Func`1 getter, Func`1 factory, ResolutionList resolutionPath)
   at BoDi.ObjectContainer.FactoryRegistration.ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
   at BoDi.ObjectContainer.RegistrationWithStrategy.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
   at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
   at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
   at BoDi.ObjectContainer.Resolve(Type typeToResolve, String name)
   at BoDi.ObjectContainer.Resolve[T](String name)
   at BoDi.ObjectContainer.Resolve[T]()
   at SolidToken.SpecFlow.DependencyInjection.DependencyInjectionPlugin.CustomizeFeatureDependenciesEventHandler(Object sender, CustomizeFeatureDependenciesEventArgs args) in ..\SpecFlow.DependencyInjection.BugReproduction\SpecFlow.DependencyInjection\DependencyInjectionPlugin.cs:line 77
   at TechTalk.SpecFlow.Plugins.RuntimePluginEvents.RaiseCustomizeFeatureDependencies(ObjectContainer featureContainer)
   at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.CreateFeatureContainer(IObjectContainer testThreadContainer, FeatureInfo featureInfo)
   at TechTalk.SpecFlow.Infrastructure.ContextManager.InitializeFeatureContext(FeatureInfo featureInfo)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnFeatureStartAsync(FeatureInfo featureInfo)
   at TechTalk.SpecFlow.TestRunner.OnFeatureStartAsync(FeatureInfo featureInfo)
   at SolidToken.SpecFlow.DependencyInjection.Tests.Features.CalculatorFeature.FeatureSetupAsync()
   at SolidToken.SpecFlow.DependencyInjection.Tests.Features.CalculatorFeature.FixtureData.Xunit.IAsyncLifetime.InitializeAsync()
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 90



-----

System.NullReferenceException
Object reference not set to an instance of an object.
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.GetHookContainer(HookType hookType)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEventsAsync(HookType hookType)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnFeatureEndAsync()
   at TechTalk.SpecFlow.TestRunner.OnFeatureEndAsync()
   at SolidToken.SpecFlow.DependencyInjection.Tests.Features.CalculatorFeature.FeatureTearDownAsync()
   at SolidToken.SpecFlow.DependencyInjection.Tests.Features.CalculatorFeature.FixtureData.Xunit.IAsyncLifetime.DisposeAsync()
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 90

DLL is not copied to NCrunch workspace since 0.6.0

Hi there!

We've had issues using NCrunch with the plugin latest version 0.6.0.

I understand that NCrunch might not be an official "supported" test runner, but I'd still like to know if we can make it work again.

FYI, here's a conversation I've had with the NCrunch team, which explains that with 0.4.0, the dll is successfully copied to the NCrunch workspace, but is not with 0.6.0: https://forum.ncrunch.net/yaf_postst3065_Package-Reference-no-longer-copied-after-being-updated.aspx

The problem is that when the file isn't copied, Specflow won't load the plugin.
When using the Visual Studio test runner, it works fine.

It looks to me like it's this removal that make the file not to be copied to the workspace folder anymore:
679f8f1#diff-d801e55d67289561fed2dabe4129bd8e01f3c4652c69bea6b744e938582ba45b

From what I understand, the documentation recommends that this file should be present: https://docs.specflow.org/projects/specflow/en/latest/Extend/Plugins.html#build-specflow-sampleplugin-props

Am I missing something? Was this removal intentional and related to some updates to SpecFlow?
Would it be possible to bring it back?

Thank you

RegisterProxyBindings does not register step context

image

I got this error when tried to configure ReportPortla nuget:
TechTalk.SpecFlow.SpecFlowException: Container of the steps class has not been initialized!
at TechTalk.SpecFlow.Steps.AssertInitialized()
at TechTalk.SpecFlow.Steps.get_ScenarioContext()
at ReportPortal.SpecFlowPlugin.ReportPortalHooks.BeforeScenario()

image

Buy I can get StepContext from ScenarioContext

image

Tests ran in parallel clash with each other

Hi there,

We've been playing around with this SpecFlow plugin, and got it to work for us except for one issue: we don't seem to be able to run tests in parallel.

For example, the ScenarioContext gets shared between different scenarios that execute at the same time. Another example is that we'd get a clash in the [ScenarioDependencies] method if we don't put a lock in it.

Is the reason for this related to the limitations described in PR #74?

The given key 'Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope' was not present in the dictionary.

C#, .net core 5.0. Specflow 3.10.2, SolidToken.SpecFlow.DependencyInjection 3.9.3
All hooks are running, after i get this issue.
I've added and implemented this nuget like this:

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using POS.BusinessLogic.Database.Employee;
using POS.BusinessLogic.DetailContainer;
using POS.BusinessLogic.Requests.Payment;
using POS.BusinessLogic.Requests.Pops;
using POS.BusinessLogic.Requests.Stall;
using POS.BusinessLogic.Services.PaymentEmulator;
using POS.BusinessLogic.Services.PopsEmulator;
using POS.BusinessLogic.Services.StallEmulator;
using POS.Core.Environment;
using POS.Core.Nats;
using POS.Core.StallStorage;
using Serilog;
using Serilog.Core;
using SolidToken.SpecFlow.DependencyInjection;

namespace POS.Steps.Hooks
{
public static class CreateServicesHooks
{
[ScenarioDependencies]
public static IServiceCollection CreateServices()
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();

        var services = new ServiceCollection();

        services
            .Configure<DbOptions>(configuration.GetSection("dpOptions"))
            .Configure<NatsOptions>(configuration.GetSection("natsOptions"))
            .Configure<AppOptions>(configuration.GetSection("appOptions"))
                
            .AddSingleton<INatsConnectionFactory, NatsConnectionFactory>()
            .AddSingleton<INatsSender, NatsSender>()
            .AddSingleton<INatsReader, NatsReader>()
            
            .AddSingleton<IDbEmployee, DbEmployee>()
            
            .AddSingleton<IContainer, Container>()
            
            .AddSingleton<IPopsRequests, PopsRequests>()
            .AddSingleton<IStallRequests, StallRequests>()
            .AddSingleton<IPaymentRequests, PaymentRequests>()
            
            .AddSingleton<IPopsService, PopsService>()
            .AddSingleton<IStallService, StallService>()
            .AddSingleton<IPaymentEmulator, PaymentEmulator>()
            
            .AddSingleton<Logger>();
    
        return services;
    }
}

}

StackTrace:
System.Collections.Generic.KeyNotFoundException : The given key 'Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope' was not present in the dictionary.
at System.Collections.Concurrent.ConcurrentDictionary2.ThrowKeyNotFoundException(TKey key) at System.Collections.Concurrent.ConcurrentDictionary2.get_Item(TKey key)
at SolidToken.SpecFlow.DependencyInjection.DependencyInjectionPlugin.<>c.b__9_22(IServiceProvider sp)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at SolidToken.SpecFlow.DependencyInjection.DependencyInjectionTestObjectResolver.ResolveBindingInstance(Type bindingType, IObjectContainer container)
at TechTalk.SpecFlow.ScenarioContext.GetBindingInstance(Type bindingType)
at lambda_method37(Closure , IContextManager , String , EmployeeInfo )
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBindingAsync(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, DurationHolder durationHolder)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatchAsync(BindingMatch match, Object[] arguments, DurationHolder durationHolder)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepAsync(IContextManager contextManager, StepInstance stepInstance)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStepAsync()
at TechTalk.SpecFlow.TestRunner.CollectScenarioErrorsAsync()
at POS.FeatureFiles.InStore.Basket.Item.ItemDisplayFeature.ScenarioCleanupAsync()
at POS.FeatureFiles.InStore.Basket.Item.ItemDisplayFeature.ClientCanSeeSplitLabelIfOrderWasSplitted() in C:\pops-automation\POS.FeatureFiles\InStore\Basket\Item\ItemDisplay.feature:line 55
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter1.GetResult() at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func1 invoke)
at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.b__0()
at NUnit.Framework.Internal.Commands.DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

Locally: issues building testproject with both targetframeworks

Hi,

I have a question,

For some reason I have build errors locally (tested on 2 machines), when both targetframeworks are enabled.

This works:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
    <RootNamespace>SolidToken.SpecFlow.DependencyInjection.Tests</RootNamespace>
    <AssemblyName>SolidToken.SpecFlow.DependencyInjection.Tests</AssemblyName>
  </PropertyGroup>

This also:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp3.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
    <RootNamespace>SolidToken.SpecFlow.DependencyInjection.Tests</RootNamespace>
    <AssemblyName>SolidToken.SpecFlow.DependencyInjection.Tests</AssemblyName>
  </PropertyGroup>

And this gives a lot of strange build errors:

 <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
    <RootNamespace>SolidToken.SpecFlow.DependencyInjection.Tests</RootNamespace>
    <AssemblyName>SolidToken.SpecFlow.DependencyInjection.Tests</AssemblyName>
  </PropertyGroup>
1>------ Build started: Project: SpecFlow.DependencyInjection.Tests, Configuration: Debug Any CPU ------
1>SpecFlowFeatureFiles: ContextInjectionScope.feature;DependencyInjectionPlugin.feature
1>SpecFlowGeneratedFiles: ContextInjectionScope.feature.cs
1>SpecFlowGeneratedFiles: DependencyInjectionPlugin.feature.cs
1>SpecFlowFeatureFiles: ContextInjectionScope.feature;DependencyInjectionPlugin.feature
1>SpecFlowGeneratedFiles: ContextInjectionScope.feature.cs
1>SpecFlowGeneratedFiles: DependencyInjectionPlugin.feature.cs
1>SpecFlow.DependencyInjection.Tests -> D:\github\304NotModified\SpecFlow.DependencyInjection\SpecFlow.DependencyInjection.Tests\bin\Debug\netcoreapp3.1\SolidToken.SpecFlow.DependencyInjection.Tests.dll
1>DependencyInjectionPlugin.feature(3,107,3,173): error CS0246: The type or namespace name 'SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?)
1>ContextInjectionScope.feature(3,99,3,165): error CS0246: The type or namespace name 'SolidToken_SpecFlow_DependencyInjection_Tests_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?)
1>ContextInjectionScope.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttributeAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(53,39,53,50): error CS0246: The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>DependencyInjectionPlugin.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttributeAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>DependencyInjectionPlugin.feature(53,16,53,38): error CS0234: The type or namespace name 'SkippableFactAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>DependencyInjectionPlugin.feature(53,39,53,50): error CS0246: The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>ContextInjectionScope.feature(17,16,17,38): error CS0234: The type or namespace name 'SkippableFactAttributeAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(17,16,17,38): error CS0234: The type or namespace name 'SkippableFactAttribute' does not exist in the namespace 'Xunit' (are you missing an assembly reference?)
1>ContextInjectionScope.feature(17,39,17,50): error CS0246: The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "SpecFlow.DependencyInjection.Tests.csproj".
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Any idea what's wrong? It's working with you guys?

I'm using Visual Studio 2019 16.4.5 (also the same issue was on 16.4.4, just updated and retested it)

Unable to resolve IUnitTestRuntimeProvider

When SpecFlow.DependencyInjection is used to configure dependencies it's no longer possible to inject IUnitTestRuntimeProvider dependency.

E.g.

namespace SolidToken.SpecFlow.DependencyInjection.Tests
{
    // ...
    [Binding]
    public class ContextInjectionScopeSteps
    {
        private readonly TestContext _context;
        private readonly IUnitTestRuntimeProvider _provider;

        public ContextInjectionScopeSteps(TestContext context, IUnitTestRuntimeProvider provider)
        {
            _context = context;
            _provider = provider;
        }
    // ...

This will produce an exception:

SolidToken.SpecFlow.DependencyInjection.Tests.ContextInjectionScopeFeature.AssertContextIsScopedToScenarioExecution

System.InvalidOperationException: Unable to resolve service for type 'TechTalk.SpecFlow.UnitTestProvider.IUnitTestRuntimeProvider' while attempting to...

System.InvalidOperationException
Unable to resolve service for type 'TechTalk.SpecFlow.UnitTestProvider.IUnitTestRuntimeProvider' while attempting to activate 'SolidToken.SpecFlow.DependencyInjection.Tests.ContextInjectionScopeSteps'.
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Reflection.ParameterInfo[] parameters, System.Boolean throwIfCallSiteNotFound) [0x00048] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache lifetime, System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00079] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain, System.Int32 slot) [0x00073] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00018] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x0002e] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+<>c__DisplayClass7_0.<GetCallSite>b__0 (System.Type type) [0x00000] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs:1002 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) [0x00014] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor (System.Type serviceType) [0x0000c] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs:1002 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00013] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00008] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <2b9439bb001b4b6dbb9ed803b6ffd532>:0 
  at SolidToken.SpecFlow.DependencyInjection.DependencyInjectionTestObjectResolver.ResolveBindingInstance (System.Type bindingType, BoDi.IObjectContainer scenarioContainer) [0x00008] in /Users/ipcholko/Documents/__RND/SpecFlow.DependencyInjection/SpecFlow.DependencyInjection/DependencyInjectionTestObjectResolver.cs:12 
  at TechTalk.SpecFlow.ScenarioContext.GetBindingInstance (System.Type bindingType) [0x0000d] in <9c7e9a29b47547ca84af875086ce214a>:0 
  at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,TechTalk.SpecFlow.Infrastructure.IContextManager,int)
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 
  at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding (TechTalk.SpecFlow.Bindings.IBinding binding, TechTalk.SpecFlow.Infrastructure.IContextManager contextManager, System.Object[] arguments, TechTalk.SpecFlow.Tracing.ITestTracer testTracer, System.TimeSpan& duration) [0x0010c] in <9c7e9a29b47547ca84af875086ce214a>:0 
  at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch (TechTalk.SpecFlow.Bindings.BindingMatch match, System.Object[] arguments, System.TimeSpan& duration) [0x00029] in <9c7e9a29b47547ca84af875086ce214a>:0 
  at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep (TechTalk.SpecFlow.Infrastructure.IContextManager contextManager, TechTalk.SpecFlow.Bindings.StepInstance stepInstance) [0x0008b] in <9c7e9a29b47547ca84af875086ce214a>:0 
  at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep () [0x0020f] in <9c7e9a29b47547ca84af875086ce214a>:0 
  at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors () [0x00000] in <9c7e9a29b47547ca84af875086ce214a>:0 
  at SolidToken.SpecFlow.DependencyInjection.Tests.ContextInjectionScopeFeature.ScenarioCleanup () [0x00001] in <af1b6c384b9c45c992845c3bee496821>:0 
  at SolidToken.SpecFlow.DependencyInjection.Tests.ContextInjectionScopeFeature.AssertContextIsScopedToScenarioExecution () [0x0016d] in /Users/ipcholko/Documents/__RND/SpecFlow.DependencyInjection/SpecFlow.DependencyInjection.Tests/ContextInjectionScope.feature:11 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 



Given I have test context with number 5
-> error: Unable to resolve service for type 'TechTalk.SpecFlow.UnitTestProvider.IUnitTestRuntimeProvider' while attempting to activate 'SolidToken.SpecFlow.DependencyInjection.Tests.ContextInjectionScopeSteps'. (0.1s)
When I multiply the test context number by 2
-> skipped because of previous errors
And I increase the test context number by 3
-> skipped because of previous errors
Then the test context number should be 13
-> skipped because of previous errors

Is there are a way to configure this dependency?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.