Jimmy Bogard, wrote an article: Getting value out of your unit tests, where he gives four rules:
- Test names should describe the what and the why, from the user’s perspective
- Tests are code too, give them some love
- Don’t settle on one fixture pattern/organizational style
- One Setup, Execute and Verify per Test
In your opinion these guidelines are complete? What are your guidelines for unit tests?
Please avoid specific language idioms, try to keep answers language-agnostic .
There’s an entire, 850 page book called xUnit Test Patterns that deal with this topic, so it’s not something that can be easily boiled down to a few hard rules (although the rules you mention are good).
A more digestible book that also covers this subject is The Art of Unit Testing.
If I may add the rules I find most important, they would be: