How to run specflow feature files in parallel?

假如想象 提交于 2019-12-10 22:55:48

问题


I am using specflow with NUnit on Saucelabs. I need to run features files in parallel . But I read somewhere that you cannot run in parallel if you are using ScenarioContext/FeatureContext which I am currently using in almost every test scenario. Is it true ? If true , what alternative can I use for multi threading. Please note that there is no dependency between the features or between the testcases in features. Can anyone provide a code snippet to help me implement parallel execution. Thanks for the help in advance.

[If not feature files in parallel , please do guide in running test scenarios within a feature file in parallel]


回答1:


If you want to make all your tests within one project run in serial add the following to the project's AssemblyInfo class:

[assembly: CollectionBehavior(DisableTestParallelization = true)]



回答2:


About ScenarioContext/FeatureContext:
If you use the Current- Properties you can not access these when you are running in parallel.
But you can get to the Contexts via Context Injection (http://www.specflow.org/documentation/ScenarioContext/, at the end).

About running in parallel:
Have a look for it in the documentation here: http://www.specflow.org/documentation/parallel-execution/
There is also a description about the *Context.Current handling.



来源:https://stackoverflow.com/questions/39894392/how-to-run-specflow-feature-files-in-parallel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!