Open 7timus opened 6 months ago
I also noticed the problem with MSTest while running tests in parallel. I duplicated (20 features) the same Calculator feature from the example project and using runsettings configured ClassLevel parallelization on 8 workers. This gives me some null ref exceptions from random tests at each run.
AddTwoNumbers
Source: Calculator - Copy (15).feature line 9
Duration: 1.6 sec
Message:
Test method CalculatorSelenium.Specs.Features.Calculator221111Feature.AddTwoNumbers threw exception:
BoDi.ObjectContainerException: Object container disposed
Stack Trace:
ObjectContainer.AssertNotDisposed()
ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
ObjectContainer.Resolve[T](String name)
MSTestTraceListener.WriteToolOutput(String message)
TestTracer.TraceWarning(String text)
InternalContextManager`1.Init(TContext newInstance, IObjectContainer newObjectContainer)
ContextManager.InitializeScenarioContext(ScenarioInfo scenarioInfo)
TestExecutionEngine.OnScenarioInitialize(ScenarioInfo scenarioInfo)
TestRunner.OnScenarioInitialize(ScenarioInfo scenarioInfo)
Calculator221111Feature.ScenarioInitialize(ScenarioInfo scenarioInfo)
Calculator221111Feature.AddTwoNumbers() line 9
I would advised all to not use Specflow+ Runner or LivingDoc as its currently not being supported or developed - migrate to MsTest or Nunit and also update to latest .net 8+ and use third party reporting libraries such as extent report.
Specflow is working perfectly fine for me with the above changes in the following daily github actions repo -> https://github.com/DeLaphante/CynkyAutomation/actions
SpecFlow Version
3.8.7
Which test runner are you using?
MSTest
Test Runner Version Number
3.8.7
.NET Implementation
.NET Core 3.1
Project Format of the SpecFlow project
Sdk-style project format
.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation NuGet package
Test Execution Method
Visual Studio Test Explorer
SpecFlow Section in app.config or content of specflow.json
No response
Issue Description
When running tests with MSTest from OutputAPI example project the ISpecFlowOutputHelper in BrowserDriver.cs dispose method throws null reference exception on disposal. This happens due to already disposed ObjectContainer that is accessed by MSTestContextProvider
Stack trace:
Steps to Reproduce
Clone https://github.com/SpecFlowOSS/SpecFlow-Examples/tree/master/OutputAPI/CalculatorSelenium/CalculatorSelenium.Specs. Change NUnit to MSTest adapter and run any of the tests.
Link to Repro Project
https://github.com/SpecFlowOSS/SpecFlow-Examples/tree/master/OutputAPI/CalculatorSelenium/CalculatorSelenium.Specs