I’ve been going through Pat’s example story and noticed that there was
no checking for a bad login. I assume this is because that would have
made the article bigger and more complicated than it needed to be.
So the question that comes of of this is:
How do folks normally handle the negative case? My plan was to just
use another scenario, but as a new person to BDD/TDD, etc, I didn’t
want to start teaching myself bad habits.
So my thought was to do something like:
Story “The saga of the login” do
Scenario “Good login” do
Given “a valid user/pass pair”, “gooduser”, “goodpass” do
#my needed code
end
Then “User should login ok” do
# more needed code
end
end
Scenario “Bad login” do
Given “a invalid user/pass pair”, “baduser”, “badpass” do
#my needed code
end
Then “User should get rejected” do
# more needed code
end
end
end
Another idea was to do this:
Story “The saga of the login” do
Scenario “Good login” do
Given “Logging in” do
#my needed code
end
When “with a valid user/pass pair”, “gooduser”, “goodpass” do
#my needed code
end
Then “User should login ok” do
# more needed code
end
When “with an invalid user/pass pair”, “baduser”, “badpass” do
#my needed code
end
Then “User should get rejected” do
# more needed code
end
end
end
This doesn’t even address the issue of a good user with a bad password,
but that seemed like overkill.
The second seemed more fluid for me.
Do people even bother with this level of granularity?
I’m probably over complicating the problem.
Thanks for any insight you can provide.
Mike B.