我是Specflow的新手,所以这里是;
我的下面的例子我应该测试一下坏吗?如果我这样做,表不会让你添加一个坏的值。所以代码会出错,因为它会像坏类型一样进入。我想我只需要知道其他人如何处理验证用户无法输入错误数据? (字段名称因保密信息而更改) 要求说:
确认用户无法将费率设置为负数或大于1.费率范围为0.9999至0.
确认用户无法输入超过4位小数的费率。
Given the lc does not exist
| Lc |
| Test90 |
| Test00 |
When I add a Lc
| Lc | Somekind of ID| Rate |
| Test90 | 2 | 0.9999 |
| Test00 | 4 | 0 |
Then the lc should be defined
| Lc |
| Test90 |
| Test00 |
答案 0 :(得分:1)
在测试中测试2个值时,有点奇怪。
我很想像这样重写:
Scenario Outline: valid lc's can be created
Given the lc named <lc> does not exist
When I add a Lc named <lc> with Id <id> and rate <rate>
Then the lc named <lc> should be defined
Examples:
| Lc | Id | Rate |
| Test90 | 2 | 0.9999 |
| Test00 | 4 | 0 |
Scenario Outline: Invalid lc's cannot be created
Given the lc named <Lc> does not exist
When I add a Lc named <Lc> with Id <Id> and rate <Rate>
Then the lc named <Lc> should not be defined
And an error should have been raised saying the rate was invalid
Examples:
| Lc | ID | Rate |
| Test90 | 2 | 1.999 |
| Test90 | 2 | 0.99999 |
| Test90 | 2 | -0.9 |
| Test00Y | 4 | 6 |
| Test00Y | 4 | |
And an error should have been raised saying the rate was invalid
步骤显然是可选的,但表明由于费率无效,预计会失败。