Heaps of good stuff in this article from Patrick Smacchia about writing tests
The tests should be written before the functionality that is being tested’.
I don’t agree with that. Tests for a portion of code should be written at the same time as the code itself.
About Code contracts and assertions (Debug.Assert)
Assertions in tests are not much different than code contract assertions.
Although Code Contracts are way slower on compile time, which is #pain.
It is a good practice to tag a class that has been 100% covered with an arbitrary [FullCovered] attribute, because it documents that the class is, and must remain 100% covered
Great idea. The build should fail if someone is not following that rule (marked by the attribute)
…writing a complete test suite naturally leads to good design, enforcing low coupling and high cohesion.