Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 为什么Specflow会多次尝试执行相同的场景?_Multithreading_Visual Studio_Specflow_Xunit.net_Specrun - Fatal编程技术网

Multithreading 为什么Specflow会多次尝试执行相同的场景?

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 -&

我已经在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 -> 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中的某些内容干扰,但没有效果:

我不确定为什么测试会执行4次,而它已经成功了一次。问题可能是什么?如何解决?请注意,这仅适用于调用浏览器的测试。对于其他人来说,它似乎工作得很好


PS:只有在将Specflow/Specrun添加到现有的单元测试项目之后,才会发生这种情况。我已经在安装了specflow的不同解决方案中创建了多个项目,它们工作得很好。

SpecRun是专门用于specflow的TestRunner。因此,它取代了XUnit Runner

失败测试的重试由执行部分的retryCount配置控制。请参见此处的SRProfile-文档:

当前错误:是否重新生成所有*.feature.cs文件?在SpecFlow 2.0中,生成的代码发生了一些更改,因此必须重新生成这些代码。

I set
retryFor=“None”
。然而,测试并没有真正失败。它总是成功,而且似乎仍在重试,然后由于跟踪侦听器异常的原因失败。对于*.feature.cs文件,我刚刚删除了它们,并让它们再次自动生成。