Multithreading 为什么Specflow会多次尝试执行相同的场景?
我已经在VisualStudio2015中将Specflow/Specrun添加到现有的单元测试项目(基于XUnit 2.0) 当我尝试执行一个场景时,它似乎尝试并执行了4次相同的事情。以下是控制台输出:Multithreading 为什么Specflow会多次尝试执行相同的场景?,multithreading,visual-studio,specflow,xunit.net,specrun,Multithreading,Visual Studio,Specflow,Xunit.net,Specrun,我已经在VisualStudio2015中将Specflow/Specrun添加到现有的单元测试项目(基于XUnit 2.0) 当我尝试执行一个场景时,它似乎尝试并执行了4次相同的事情。以下是控制台输出: Scenario: Add true/false question in AddTrueFalseQuestion -> Succeeded on thread #0 Scenario: Add true/false question in AddTrueFalseQuestion -&
Scenario: Add true/false question in AddTrueFalseQuestion -> Succeeded on thread #0
Scenario: Add true/false question in AddTrueFalseQuestion -> Failed on thread #0
[ERROR] Trace listener failed. -> The ScenarioContext.Current static accessor cannot be used in multi-threaded execution. Try injecting the scenario context to the binding class. See http://go.specflow.org/doc-multithreaded for details.
Scenario: Add true/false question in AddTrueFalseQuestion -> Failed on thread #0
[ERROR] Trace listener failed. -> The ScenarioContext.Current static accessor cannot be used in multi-threaded execution. Try injecting the scenario context to the binding class. See http://go.specflow.org/doc-multithreaded for details.
Scenario: Add true/false question in AddTrueFalseQuestion -> Failed on thread #0
[ERROR] Trace listener failed. -> The ScenarioContext.Current static accessor cannot be used in multi-threaded execution. Try injecting the scenario context to the binding class. See http://go.specflow.org/doc-multithreaded for details.
Result: 1 failed
Total: 2 (test executions: 4)
Succeeded: 1
Ignored: 0
Pending: 0
Skipped: 0
Failed: 1
我尝试过的事情:
- 根据上述错误,我已搜索以验证项目中是否有任何文件引用了
,但未找到任何内容ScenarioContext.Current
- specflow的default.sprofile测试配置文件具有以下配置,但不确定是否遵守该配置文件:
- 我甚至尝试在App.config中添加以下内容,以防XUnit中的某些内容干扰,但没有效果:
PS:只有在将Specflow/Specrun添加到现有的单元测试项目之后,才会发生这种情况。我已经在安装了specflow的不同解决方案中创建了多个项目,它们工作得很好。SpecRun是专门用于specflow的TestRunner。因此,它取代了XUnit Runner 失败测试的重试由执行部分的retryCount配置控制。请参见此处的SRProfile-文档: 当前错误:是否重新生成所有*.feature.cs文件?在SpecFlow 2.0中,生成的代码发生了一些更改,因此必须重新生成这些代码。I set
retryFor=“None”
。然而,测试并没有真正失败。它总是成功,而且似乎仍在重试,然后由于跟踪侦听器异常的原因失败。对于*.feature.cs文件,我刚刚删除了它们,并让它们再次自动生成。