SpecFlow:System.FormatException:输入字符串的格式不正确

时间:2015-04-01 14:38:34

标签: c# bdd specflow

使用SpecFlow运行测试时出现以下错误:

System.FormatException: Input string was not in a correct format.

我花了一段时间才弄清楚它为什么会发生。

2 个答案:

答案 0 :(得分:6)

最后是因为我在其中一个步骤定义中省略了单引号,例如:

[Then(@"Something adds up to a quantity of (.*)")]

应该是什么时候

[Then(@"Something adds up to a quantity of '(.*)'")]

请注意(。*)

周围的单引号

答案 1 :(得分:0)

遇到此问题时要寻找的另一件事是验证参数。

When I update the thing by Id (<Id>)

Examples:
  | Name |
  | 1    |

这里的问题是示例表中的“Id”与“Name”不匹配