I am trying to develop a Delete command through BDD that will simply delete an user from the database, given user_id as a parameter. What can be some possible behavioral tests that will drive me to write a proper implementation for the command?
1 Answer
Here are some possible tests:
- (Delete works) When
user_idis in the database, ifdelete(user_id)is called,user_idwill no longer be in the database - (Delete affects only one record) When
user_idis in the database, and there are other users as well, ifdelete(user_id)is called, the other users will still be in the database - (Delete no-op) When
user_idis not in the database, ifdelete(user_id)is called,user_idshould still not be in the database (or maybe an exception gets thrown; depends on your spec)
-
Thanks a lot. One more thing, for steps such as 1, we have to do state verification right? (e.g.,
assertEquals(getUserWithId(user_id), null)). In many resources about introducing BDD, I have seen examples of doing behavior verification, but not much of state verification. Is it normal to mix state verification as well as behavior verification while doing BDD? I am asking because it seems to me we can't substitute one for the other.Samir Hasan– Samir Hasan2013-03-01 08:44:42 +00:00Commented Mar 1, 2013 at 8:44 -
1@SamirHasan: Add a couple of examples and links to those resources and that's a great question. However, "One more thing ..." rarely makes a good comment.pdr– pdr2013-03-01 08:58:26 +00:00Commented Mar 1, 2013 at 8:58