SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.25k stars 754 forks source link

The previous ScenarioContext was already disposed #2751

Closed omercanxx closed 3 months ago

omercanxx commented 6 months ago

SpecFlow Version

3.9.52

Which test runner are you using?

xUnit

Test Runner Version Number

2.4.3

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Classic project format using <PackageReference> tags

.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

Hello,

I've encountered an issue with SpecFlow tests that intermittently fail in our CI pipeline. This problem seems to be related to the ScenarioContext being disposed unexpectedly during test execution. Here are the details:

In our project, we have approximately 1500 tests running on a CI pipeline. While these tests pass consistently when run locally, they intermittently fail in the pipeline environment. Upon investigation, I noticed the following error message in the logs:

The previous ScenarioContext was already disposed

Steps to Reproduce

I dont know how can reproduce the steps. It works on my machine 😅

Link to Repro Project

No response

DeLaphante commented 4 months ago

@omercanxx how many threads can your machine run or core does it have compared to your CI/CD server? - how many parallel threads have you set in your config?

anastasiiakuzina-payroc commented 4 months ago

We had that with xunit on the pipeline as well. Similar issue that we have in our notes we found at a time is https://github.com/SpecFlowOSS/SpecFlow/issues/1399

in our case it seemed to happen when there was a number of tests > 100 we upgraded xunit to latest and that resolved the issue. We did switch to mstest after and did not see that issue with mstest. Hope it helps.

omercanxx commented 3 months ago

My tests were failing because I missed using await in an asynchronous method. Thanks for your help

github-actions[bot] commented 2 months ago

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.