【发布时间】:2016-05-09 20:20:56
【问题描述】:
我有这个 Specflow 功能:
Given I have CoolData with <a> , <b> , <c> and <d>:
| a | b | c | d |
| cool data | | 1.3 | Cool notes |
| cool data | 1.4 | | Cool notes |
| cool data | 1.3 | 1.3 | Cool notes |
| cool data | 1.3 | 1.3 | Cool notes |
我有这个方法:
[Given(@"Given I have CoolData with (.*) , (.*) , (.*) and (.*) :")]
public void GivenIhaveCoolDatawithAnd(string p0, string p1, string p2, string p3, Table table)
{
var cool = new CoolData
{
a= p0,
b= decimal.Parse(p1),
c= decimal.Parse(p2),
d= p3,
};
}
我的问题:当我运行这个测试时,p0、p1、p2 和 p3 被映射到字面意思为 "<a>"、"<b>"、"<c>" 和 "<d>" 的字符串,而不是表中的值。我究竟做错了什么?我正在尝试对此表中的每一行重复单元测试。
【问题讨论】:
-
看起来您只需要跳过包含列标题的第一行数据。