用户输入验证的 Gherkin 场景

发布于 2024-08-29 08:48:22 字数 216 浏览 0 评论 0原文

当编写验证输入表单上的信息的 BDD 场景时,您将如何列出规则。

选项有:

1) 每个规则一个场景 2)场景大纲,包含每个字段和规则的示例

我们如何说不属于特定字符集中的内容无效,例如:

假设我输入了一个违​​反规则的值.. 当我做某事时 然后我应该看到一个错误......

你会生成违反规则的随机值吗?

谢谢, 詹姆斯

When writing a BDD scenario that is validating information on an input form, how would you list rules.

Options are:

1) A single scenario each rule
2) Scenario outline with examples for each field and rule

How do we say something is invalid that is not in a certain character set, e.g:

Given I enter a value that breaks the rule..
When I do something
Then I should see an error .....

Would you generate random values that break the rule?

Thanks,
James

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乜一 2024-09-05 08:48:22

通过验证,我做了其中之一:

  • 验证可能出错的每种情况,或者
  • 通过单元测试捕获验证行为,然后描述我(用户)将如何看到验证消息
  • 捕获用户常见的事情做错了,并描述了系统将如何帮助我改正。

我发现第二个和第三个更容易维护,特别是使用 BDD 工具,因为英语很难重构并且验证规则经常发生变化。如果没有提供更高级别的业务能力,就像第三种情况,那么我就做第二种。

BDD 并不是真正的测试。这是关于达成共同的理解并以有助于将这种理解融入到代码中的方式来捕获它。你得到的测试是一个美妙的副产品。

希望有帮助。

With validation, I've done one of these:

  • validated each kind of thing that might go wrong, or
  • captured the validation behaviour with unit tests, then just described how I, the user, will see the validation message
  • captured the common things that users do wrong and described how the system will help me to get it right.

I find the second and third ones easier to maintain, especially using a BDD tool, given that English is hard to refactor and validation rules often change. If there's no higher-level business capability which is provided, as in the third situation, then I'd just do the second one.

BDD isn't really about testing. It's about coming to a shared understanding and capturing that in a way which helps that understanding play into the code. You get tests as a wonderful by-product.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文