I like it when people read cucumber tests, so assuming we have a story for editing foobar with invalid data, I need a script like:
I think that it captures what we want from history, without dealing with all the details about which fields to edit, which buttons to send, etc. It does not check all possible cases, but they should really be tested using unit tests (model tests that are installed for verification, and control tests install flash messages or request tests that serve errors).
Other scenarios are similar:
Scenario: Successful Edit Given I am logged in as a user And a foobar exists And I edit the foobar with valid data Then I should see the valid data
Some people will want to provide valid data as part of the test itself, but I personally prefer to delegate it to the step definitions to keep the scripts clean. You just need one example to make sure the golden case works, because again this is not the right place to check that all form fields are working (and this will become a maintenance headache if you specify each individual field).
Ben taitelbaum
source share