Visual Studio 2017 C#
我发现运行场景大纲它将多次运行测试,因此当我构建时,我可以在测试运行器中看到示例行中的所有测试。 当我执行其中一个测试时,当我运行单个测试而不是父组时,它似乎执行每个示例和行。
这也发生在为其创建的 Jenkins 作业中,它会检查代码构建和执行的新副本。该作业花了 7 个小时,因为每行都运行每个测试,所以如果我有 10 行,它将运行 100 次,因为每行将运行 10 次,这意味着每个测试执行 10 次。
这是如何发生的以及如何防止它。
最佳答案
场景大纲是带有参数的场景。您可以在一个或多个示例表中指定它们。表中的每一行都是一个示例,因此也是一个场景。
它们就像 XUnit 中的理论。
以下是 Gherkin 引用文档 ( https://cucumber.io/docs/reference#scenario-outline ) 中的示例:
Scenario Outline: feeding a suckler cow
Given the cow weighs <weight> kg
When we calculate the feeding requirements
Then the energy should be <energy> MJ
And the protein should be <protein> kg
Examples:
| weight | energy | protein |
| 450 | 26500 | 215 |
| 500 | 29500 | 245 |
| 575 | 31500 | 255 |
| 600 | 37000 | 305 |
关于c# - Specflow 场景大纲未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48927837/