gpt4 book ai didi

Specflow/小 cucumber : How to handle bad data

转载 作者:行者123 更新时间:2023-12-02 03:24:39 31 4
gpt4 key购买 nike

我是 Specflow 的新手,所以开始吧;

对于我下面的例子,我应该测试坏的吗?如果我这样做,表格不会让您添加错误的值。所以代码会出错,因为它以错误的类型出现。我想我只需要知道其他人如何处理验证用户不能输入错误数据? (由于 secret 信息,字段名称已更改)要求说:

验证用户不能将比率设置为负数或大于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 |

最佳答案

在整个测试过程中测试 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 这一步显然是可选的,但它表明由于无效率预计会失败。

关于Specflow/小 cucumber : How to handle bad data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31075411/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com