specflow - 您可以使用参数/变量/占位符作为未来在 Specflow 场景中使用的值吗?
问题描述
在以前的工作中,我使用 DBFit 并使用参数(变量/占位符)作为值
例子:
|Key? |
|>>Key|
!|Query|SELECT Status FROM Confirm WHERE Name='xyz' |
| Status | Key |
| Confirmed | <<Key |
我现在正在使用 SpecFlow 并想知道它是否具有类似的功能
示例:(我在这里使用 << 和 >> 只是为了解释)
鉴于我得到 Initial for 并且第一个响应应该包含
| Name | string | "xyz" |
| Key | string | >>{Key} |
当我得到确认时
那么第一个响应应该包含
| Name | string | "xyz" |
| Key | string | <<{Key} |
解决方案
我认为您正在寻找方案大纲。
使用它们,您可以使用参数指定一个表。所以在你的情况下,它看起来像这样:
Scenario Outline: Title for your Scenario Outline
Given I get Initial for And the 1st response should contain
| field | type | assertion |
| Name | string | "xyz" |
| Key | string | <Key> |
When I get Confirm for
Then the 1st response should contain
| field | type | assertion |
| Name | string | "xyz" |
| Key | string | <Key> |
Examples:
| Key |
| example1 |
| example2 |
| example3 |
请注意,这里有两种不同类型的表。步骤中的表格是步骤的参数。最后的示例表是具体示例。因此,该表中的每个条目都会执行一次场景。
您可以将示例表中的参数与简单的 <COLUMN_NAME> 占位符一起使用。
推荐阅读
- css - 更智能的 CSS 颜色更改
- javascript - 如何使用 .noConflict 解决 3 个或更多从属 JQuery 版本之间的 JQuery 冲突?
- android - 错误空指针。(io.reactivex.Scheduler)' 在空对象引用上
- javascript - 我可以从嵌套回调中的“异步”函数返回吗?
- angular - 具有providedIn的子类的依赖注入:root
- javascript - 如何访问'key'对象reactJS的对象属性
- java - PKIX 路径构建失败:无法找到请求目标的有效证书路径 - 导入的 CERT
- javascript - 在锚标记内使图标可点击
- byte - little-endian 中的 8 位数字和 big-endian 中的 8 位数字之间的区别
- node.js - 如何提取单个数组中的所有金额?