Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
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. –  Kilian Foth Mar 1 '13 at 7:18
add comment

1 Answer 1

up vote 5 down vote accepted

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)
share|improve this answer
    
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 Mar 1 '13 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 Mar 1 '13 at 8:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.