我已经在Visual Studio 2015中将Specflow/Specrun添加到现有的单元测试项目(基于XUnit 2.0)。为什么Specflow试图多次执行相同的场景?
当我尝试执行单个场景时,它似乎尝试并执行相同的操作4次。这里是控制台输出:
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测试配置文件具有以下配置,但不确定它是否被服从:
< Execution stopAfterFailures="3" testThreadCount="1" testSchedulingMode="Sequential" />
我甚至尝试加入以下的App.config的情况下,如果东西的xUnit被干扰,但无济于事:
<add key="xunit.parallelizeTestCollections" value="false"/>
我不确定为什么测试会执行4次,当它已经成功一次。可能是什么问题以及如何解决?请注意,这只发生在调用浏览器的测试中。对于其他人来说,它似乎工作得很好。 PS:只有在将Specflow/Specrun添加到现有的单元测试项目后才会发生这种情况。我在一侧创建了多个项目,它们安装了specflow并且工作得很好。
我设置了'retryFor =“None”'。但是,测试并没有真正失败。它总是成功,它似乎仍然重试,然后由于某些原因而导致这些跟踪侦听器异常失败。对于* .feature.cs文件,我刚刚删除它们并让它们自动生成。 – PhD