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
For example, validating that an input value is a credit card number may involve validating that the input value contains only numbers, is between 13 and 16 digits long, and passes the business logic check of correctly passing the Luhn formula (the formula for calculating the validity of a number based on the last “ ...
Gherkin's Golden Rule. Gherkin's Golden Rule is simple: Treat other readers as you would want to be treated. More specifically, write feature files so that everyone can intuitively understand them. Good Gherkin should improve team collaboration by clarifying behaviors you want to develop.
The Cardinal Rule is a way to break out of the procedure-driven mindset, and banning multiple When-Then pairs per Gherkin scenario is an effective rule for enforcing it.
Gherkin is a Business Readable, Domain Specific Language created especially for behavior descriptions. It gives you the ability to remove logic details from behavior tests. Gherkin serves two purposes: serving as your project's documentation and automated tests.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With