Test negative cases first
What does it mean to test negative cases first? In many computer games, especially role-playing games, it is common for the game designers to make it very difficult to win the game if you simply go straight to the boss. Instead, you must make side quests, make wrong turns, and get lost in the story before you can fight the boss. Testing is no different. Before the problem can be solved, we must first handle bad input, prevent exceptions, and resolve conflicts in the business requirements.
In the Todo application, we mistakenly flew through and added an item to the Todo list without verifying that the item was valid. Now, the sprint is over and our user interface developers are mad at us because they do not know what to do with a Todo item that has no details at all. What we should have done is handle the cases where we receive bad data first. Let's rewind and temporarily skip the test we just made.Â
[Fact(Skip="Forgot to test negative cases first")] public void ItAddsATodoItemToTheTodoList...