TDD is something that seems to be on everybody's lips these days, and I have tried some on my own but I don't think I'm getting the idea. I am getting a grip on how to write a unit test, but I don't understand exactly what my unit tests should test.
- If I have an action method that returns a list of data, what should I verify? Only that the view name is correct, or should I verify the data as well?
- If I should test the data as well, won't I be writing the same code twice? What is the use of testing the data, if I use the same method to retrieve the data I'm comparing to?
- Should I test the methods adding/editing my data too? How do I verify that a record has been added/edited/removed, in a correct way?
I know it's quite a lot of large questions, but I haven't become any wiser from reading articles on the internet, as they all seem to be concerned with how to test, and not with what.
As an example - I have (or, am going to write) a GuestbookController, with methods for viewing, adding, editing and removing posts. What do I need to test? How do I do it?