-
Notifications
You must be signed in to change notification settings - Fork 748
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
MSTest Static FeatureSetup on generated .feature.cs is a bug #96
Comments
You can find an example http://regis.ws/specflow/TestProject1.zip |
i see the problem... |
We could have one method just for kicking specflow event on ClassInitializeAttribute and another method on TestInitializeAttribute just for setting the FeatureContext. |
I think i have a fix for this now, you can test it through the build site (build.specflow.org) |
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. |
I'm using MSTest.
Lets pretend you have 2 feature files.
Feature file A has two scenarios: scenario 1 and scenario 3.
Feature file B has one scenarios : test 2.
If you have run tests order by name it will run:
Feature A - scenario 1
Feature B - scenario 2
Feature A - scenario 3
The problem is that feature info is setup on line ~33 on the Feature A.feature.cs on static method FeatureSetup.
Calling testRunner.OnFeatureStart(featureInfo);
this static method is called only once I think.
Then the tests runs:
Feature A class is created. scenario 1 runs
Feature B is created. scenario 2 runs.
scenario 3 runs with the wrong feature context from feature b
So when you go back to Feature A - scenario 3 the ObjectContainer.FeatureContext.FeatureInfo is from Feature B.
Then it messes all the StepScoped step definition. I use FeatureInfo to initialize my CSS selector helpers.
A lot of my tests are falling on a random basis depending on the order they run.
I suggest you to change the generator to write TestInitializeAttribute instead of ClassInitializeAttribute before the FeatureSetup method on .feature.cs files. So the feature info is always right.
Maybe is the same problem of #95 issue.
Thank you.
The text was updated successfully, but these errors were encountered: