Peter Gfader's brain noise
Patrick Smacchia on writing tests

Heaps of good stuff in this article from Patrick Smacchia about writing tests

Best bits

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.

Great recap!

Full article: On Writing Unit Tests for C#
http://www.simple-talk.com/dotnet/.net-framework/on-writing-unit-tests-for-c/

Blog comments powered by Disqus