用户输入验证的 Gherkin 场景
当编写验证输入表单上的信息的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过验证,我做了其中之一:
我发现第二个和第三个更容易维护,特别是使用 BDD 工具,因为英语很难重构并且验证规则经常发生变化。如果没有提供更高级别的业务能力,就像第三种情况,那么我就做第二种。
BDD 并不是真正的测试。这是关于达成共同的理解并以有助于将这种理解融入到代码中的方式来捕获它。你得到的测试是一个美妙的副产品。
希望有帮助。
With validation, I've done one of these:
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.