我正在尝试从我的specflow功能文件生成文档(pdf格式)。我正在使用Nuget上的gerkin lib来解析文件。
我有一些场景大纲,每个场景大纲有两个示例表(根据黄瓜书,完全没问题):
Scenario Outline: My scenario
Given "<this>" first value
When I enter some second "<value>"
Then the result must be equal to "<expected result>"
Examples: Some first list of values // My example name
| this | value | expected result |
| 0 | 1 | 2 |
Examples: Some second list of values // My example name
| this | value | expected result |
| A | B | C |
我遇到的问题是你解析这个文件。您可以访问所有给定的示例,但只能访问一个示例名称。因此,当您构建文档时,无法判断它是来自第一组还是第二组示例。我注意到其他工具如“泡菜”也有同样的问题。
以下是一些尝试获取每个示例名称的代码:
foreach( var feature in file.Feature.FeatureElements )
{
var example = ( ( ScenarioOutline ) ( x ) ).Example;
// this value always remain the same and is incorrect according to my feature file.
var exampleName = example.Name != exampleName
}
我重新解决问题可能是SpecFlow lib本身而不是用于解析的gerkin库 - 似乎NUnit在创建测试用例时也看不到第二个示例名称。
之前有人处理过此事吗?
PS:有人请标记scenariooutline。它与情景不同。
答案 0 :(得分:0)
Specflow不支持方案大纲中的多个示例块。为什么不把你的第二个例子放在第一个?即。
Examples:
| this | value | expected result |
| 0 | 1 | 2 |
| A | B | C |
如果你肯定想要为你可以拥有的不同类型的输入(即所有数字或所有字符)设置不同的测试场景,那么我会创建两个不同的场景轮廓,例如。
Scenario Outline: Calculate the result for numeric input
Given "<this>" first value
When I enter some second "<value>"
Then the result must be equal to "<expected result>"
Examples:
| this | value | expected result |
| 0 | 1 | 2 |
和
场景大纲:计算字母输入的结果
Given "<this>" first value
When I enter some second "<value>"
Then the result must be equal to "<expected result>"
Examples:
| this | value | expected result |
| A | B | C |