Issue with injecting ScenarioContext into Before Hooks with multithreading (MsTest) #1647
Open
9 of 32 tasks
Labels
Bug
Difficulty: hard
MSTest
old-version-used
User is not the latest major version
Parallel Execution
Runtime
Severity: medium
SpecFlow Version:
Used Test Runner
Version number: 2.4.0
Project Format of the SpecFlow project
packages.config
<PackageReference>
tags.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation
NuGet packageSpecFlowSingleFileGenerator
custom toolVisual Studio Version
Enable SpecFlowSingleFileGenerator Custom Tool
option in Visual Studio extension settingsAre the latest Visual Studio updates installed?
15.7.6
.NET Framework:
Test Execution Method:
<SpecFlow> Section in app.config or content of specflow.json
Repro Project
Issue Description
I'm running two different Testcases in parallel with mstest and I'm trying to inject the ScenarioContext into the BeforeScenario, but more often than not the ScenarioContext for one scenario has the ScenarioInfo of another Scenario. For example, when I have 2 scenarios, one called "Test1" and one called "Test2", when I check the ScenarioInfo, in the thread running "Test2", the Title value would be "Test1"
I'm injecting into the constructor with:
public TestCommon(TestcaseContext tc, ScenarioContext sc, FeatureContext fc)
{
this.tcContext = tc;
this.scenarioContext = sc;
}
Steps to Reproduce
Sometimes the first thread to hit this point has the right scenario info, but the next thread always fails with 'An item with the same key has already been added.' before hitting that breakpoint
The text was updated successfully, but these errors were encountered: