【发布时间】:2017-12-18 19:24:42
【问题描述】:
在使用场景大纲格式时,specflow 是否提供了一种从“示例”表中获取数据的方法?类似于标签在执行期间如何在场景上下文中可用。
【问题讨论】:
在使用场景大纲格式时,specflow 是否提供了一种从“示例”表中获取数据的方法?类似于标签在执行期间如何在场景上下文中可用。
【问题讨论】:
不,没有办法。
您写入示例表的示例类似于场景的参数。 这些值替换场景步骤中的占位符(它们在 括号中)
Gherkin 文档中的示例(https://cucumber.io/docs/reference - 场景大纲)
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 |
如果您使用数据表作为参数,则只能获取整个表。 示例:
Given the following users exist:
| name | email | twitter |
| Aslak | aslak@cucumber.io | @aslak_hellesoy |
| Julien | julien@cucumber.io | @jbpros |
| Matt | matt@cucumber.io | @mattwynne |
您可以使用此绑定访问它:
[Given(@"the following users exist:")
public void TheFollowinUsersExists(Table table)
{
//your code
}
【讨论】: