3

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
  • 1
    Postulate that when you delete a particular user AND THEN list your users, that user DOESN'T appear. A deletion by itself has no observable effect, you need to describe at least two steps. Commented Mar 1, 2013 at 7:18

1 Answer 1

5

Here are some possible tests:

  1. (Delete works) When user_id is in the database, if delete(user_id) is called, user_id will no longer be in the database
  2. (Delete affects only one record) When user_id is in the database, and there are other users as well, if delete(user_id) is called, the other users will still be in the database
  3. (Delete no-op) When user_id is not in the database, if delete(user_id) is called, user_id should still not be in the database (or maybe an exception gets thrown; depends on your spec)
2
  • 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. Commented 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. Commented Mar 1, 2013 at 8:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.