Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Unable to resolve IUnitTestRuntimeProvider #73

Closed
Igor-Pchelko opened this issue Nov 23, 2021 · 0 comments · Fixed by #85
Closed

Unable to resolve IUnitTestRuntimeProvider #73

Igor-Pchelko opened this issue Nov 23, 2021 · 0 comments · Fixed by #85
Assignees
Labels
bug Something isn't working

Comments

@Igor-Pchelko
Copy link

Igor-Pchelko commented Nov 23, 2021

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?

@mbhoek mbhoek self-assigned this Nov 24, 2021
@mbhoek mbhoek added the bug Something isn't working label Nov 24, 2021
@mbhoek mbhoek linked a pull request May 7, 2022 that will close this issue
@mbhoek mbhoek removed a link to a pull request May 7, 2022
mbhoek added a commit that referenced this issue May 7, 2022
@mbhoek mbhoek closed this as completed in #85 May 7, 2022
mbhoek added a commit that referenced this issue May 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants