开发者

Gherkin Scenarios for User Input Validation

开发者 https://www.devze.com 2022-12-28 00:38 出处:网络
When writing a BDD scenario that is validating information on an input form, how would you list rules.

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 开发者_StackOverflow社区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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消