Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoDi.ObjectContainerException: Interface cannot be resolved exception when retrying a failed test running in parallel #1857

Closed
9 of 33 tasks
SavitaMaurya opened this issue Jan 21, 2020 · 12 comments

Comments

@SavitaMaurya
Copy link

SavitaMaurya commented Jan 21, 2020

BoDi.ObjectContainerException: Interface cannot be resolved exception when retrying a failed test running in parallel.

When I am setting threadCount=1, this error do not occur.

I am not using any Hooks in the project.

--

SpecFlow Version:

  • 3.1
  • 3.0
  • 2.4
  • 2.3
  • 2.2
  • 2.1
  • 2.0
  • 1.9

Used Test Runner

  • SpecFlow+Runner
  • MSTest
  • NUnit
  • Xunit

Version number:

Project Format of the SpecFlow project

  • Classic project format using packages.config
  • Classic project format using <PackageReference> tags
  • Sdk-style project format

.feature.cs files are generated using

  • SpecFlow.Tools.MsBuild.Generation NuGet package
  • SpecFlowSingleFileGenerator custom tool

Visual Studio Version

  • VS 2019
  • VS 2017
  • VS 2015

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

  • Enabled
  • Disabled

Are the latest Visual Studio updates installed?

  • Yes
  • No, I use Visual Studio version <Major>.<Minor>.<Patch>

.NET Framework:

  • >= .NET 4.5
  • before .NET 4.5
  • .NET Core 2.0
  • .NET Core 2.1
  • .NET Core 2.2
  • .NET Core 3.0

Test Execution Method:

  • Visual Studio Test Explorer
  • TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK
  • Command line – PLEASE SPECIFY THE FULL COMMAND LINE

<SpecFlow> Section in app.config or content of specflow.json

{
  "bindingCulture": {
    "language": "en-us"
  },
  "language": {
    "feature": "en-us"
  },
  "plugins": [],
  "": "",
  "browser": "",
  "novasolBaseUrl": "https://www.novasol",
![bodi error](https://user-images.githubusercontent.com/47749634/72806068-acaa9000-3c54-11ea-8ae7-94d1c8624805.PNG)
  "ArrivalInDays": 20,
  "DepartureInDays": 10,
  "TotalFutureMonths": 3,

  "runtimes": {
    "win10-x64": {},
    "osx.10.10-x64": {},
    "ubuntu.18.04-x64": {}
  }

}

Repro Project

Issue Description

Steps to Reproduce

Using this Default.srprofile to run tests in parallel.

<?xml version="1.0" encoding="utf-8"?>
<TestProfile xmlns="http://www.specflow.org/schemas/plus/TestProfile/1.5">
  <Settings projectName="WebShopTestAutomation" />
  <Execution  testThreadCount="2" retryCount="1" stopAfterFailures="0"/>
  <!-- For collecting by a SpecRun server update and enable the following element. For using the 
      collected statistics, set testSchedulingMode="Adaptive" attribute on the <Execution> element. 
    -->
   <Server serverUrl="http://specrunserver:6365" publishResults="true"/>

  <Environment testThreadIsolation="SharedAppDomain" />
  <TestAssemblyPaths>
    <TestAssemblyPath>WebShopTestAutomation.dll</TestAssemblyPath>
  </TestAssemblyPaths>
  <Targets>
    <Target name="Desktop_Chrome">
      <Filter>Desktop_Chrome</Filter>
      <DeploymentTransformationSteps>
        <EnvironmentVariable variable="Test_Browser" value="Desktop_Chrome" />
      </DeploymentTransformationSteps>
    </Target>
  </Targets>
  </TestProfile>

bodi error

@SavitaMaurya SavitaMaurya changed the title BoDi.ObjectContainerException: Interface cannot be resolved **exception when retrying a failed test running in parallel BoDi.ObjectContainerException: Interface cannot be resolved exception when retrying a failed test running in parallel Jan 21, 2020
@SavitaMaurya
Copy link
Author

bodi error

@Konnor5092
Copy link

I'm getting a very similar intermittent error since upgrading SpecFlow and SpecFlow+ to 3.1.80 and 3.1.48 respectively. I was previously on 3.0.225 and 3.0.391 with no issues.

Interface cannot be resolved: TechTalk.SpecFlow.Infrastructure.ITestObjectResolver (resolution path: TechTalk.SpecFlow.ScenarioContext)

The only difference to the OP is that when I get it logged, it's not linked to a different error. OP looks like it's linked to a selenium error.

BoDi.ObjectContainerException: Interface cannot be resolved: TechTalk.SpecFlow.Infrastructure.ITestObjectResolver (resolution path: TechTalk.SpecFlow.ScenarioContext)
   at BoDi.ObjectContainer.TypeRegistration.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.<>c__DisplayClass57_0.<ResolveArguments>b__0(ParameterInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at BoDi.ObjectContainer.ResolveArguments(IEnumerable`1 parameters, RegistrationKey keyToResolve, ResolutionList resolutionPath)
   at BoDi.ObjectContainer.CreateObject(Type type, ResolutionList resolutionPath, RegistrationKey keyToResolve)
   at BoDi.ObjectContainer.TypeRegistration.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[T](String name)
   at BoDi.ObjectContainer.Resolve[T]()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.InitializeScenarioContext(ScenarioInfo scenarioInfo)
   at TechTalk.SpecRun.SpecFlowPlugin.Runtime.RunnerTestExecutionEngine.OnScenarioInitialize(ScenarioInfo scenarioInfo)
   at TechTalk.SpecFlow.TestRunner.OnScenarioInitialize(ScenarioInfo scenarioInfo)
   at Selenium.SEPA.Features.ApprenticeFeaturesFeature.ScenarioInitialize(ScenarioInfo scenarioInfo)
   at Selenium.SEPA.Features.ApprenticeFeaturesFeature.ApprenticeManagementEditExistingApprenticeDeleteNotes() in D:\a\1\s\Selenium.SEPA\Features\ApprenticeFeatures.feature:line 897
   at TechTalk.SpecRun.Framework.TaskExecutors.StaticOrInstanceMethodExecutor.ExecuteInternal(ITestThreadExecutionContext testThreadExecutionContext)
   at TechTalk.SpecRun.Framework.TaskExecutors.StaticOrInstanceMethodExecutor.Execute(ITestThreadExecutionContext testThreadExecutionContext)
   at TechTalk.SpecRun.Framework.TestNodeTask.Execute() 

I get about 10 failures from 360 tests due this error, and it's never the same 10 each time. I use context injection of the ScenarioContext extensively in various binding classes every test.

Due to the intermittent nature I can't provide a reproducible example, but it is unfortunately preventing me from upgrading.

Notable settings in my .srprofile

  <Execution stopAfterFailures="0"
             testThreadCount="15"
             testSchedulingMode="Random"
             retryFor="Failing"
             retryCount="1"
             apartmentState="MTA"  />
  <VSTest testRetryResults="Unified"
          passRateAbsolute="1" />
  <Environment testThreadIsolation="SharedAppDomain" platform="x86"/>

@SavitaMaurya
Copy link
Author

Hi Team / @SabotageAndi Any update on the above issue?

@SabotageAndi
Copy link
Contributor

No, not yet. I put it in the next sprint that starts tomorrow.

@SabotageAndi
Copy link
Contributor

@SavitaMaurya @Konnor5092
I looked into this issue, but could not reproduce it.
Could you create a new project where you can reproduce this issue?

Btw, are you using SpecFlow.Autofac?

@cosminPintea
Copy link

cosminPintea commented Feb 17, 2020

Hi,
I think is the same issue as mine
"Exception when trying to run features in parallel: BoDi.ObjectContainerException : Interface cannot be resolved 1873"

I have not used "specflow+" but I have created my own runner. There are steps that can reproduce my issue.
@Konnor5092 - Yes, i have downgraded my specflow environment to 3.0.225 and don't get that exception. It could be caused by some race condition because in my runs, it fails all the time (use my code to start a parallel run, not specflow+).

The conditions when the exception happens:

  1. There are three feature files. One feature file contains a short scenario, that will finish first when the three scenarios are started in parallel.
  2. The two feature file contains 2 scenarios both.

The execution order should be :

  1. the first feature file is executed and finish successfully (the shorter one with one scenario)
  2. One of the remaining two feature finish execution of the first scenario (the second feature with two scenarios still executing the first scenario)
  3. The fail happen when the test engine (nUnit) tries to start the second scenario.

Regards,
Cosmin

@SavitaMaurya
Copy link
Author

SavitaMaurya commented Feb 24, 2020

Hi @SabotageAndi Sorry, couldn't reply earlier. I get this error daily when our regression suite having many tests targeting multiple browsers run in parallel.

Have created this repository and intentionally failing the test by using an Assert statement to reproduce this issue. As I have observed once a test fails in suite because of any error timeout, assertion fails, etc this error starts appearing.

https://github.com/SavitaMaurya/SpecflowSampleCode/tree/master

Check the TestResults folder to see a already checked in report.

@SavitaMaurya
Copy link
Author

Hi @SabotageAndi Do we have any update on this issue?

@SabotageAndi
Copy link
Contributor

As we stopped maintaining the SpecFlow+ Runner (https://specflow.org/using-specflow/the-retirement-of-specflow-runner/) I am closing this issue.

@summitinsights
Copy link

I'm not using the SpecFlow Runner but using SpecFlow Nunit runner and getting this error when tests run in parallel. works when I run a test manually in debug mode

@SabotageAndi
Copy link
Contributor

@summitinsights please open a new issue

@github-actions
Copy link

github-actions bot commented Mar 3, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants