Traits of Unit Tests

| Comments

A while back Michael Feathers wrote a short post about optimizing unit tests. In it he gives a list traits that prevent something from being a true unit test.

When trying to convert non-testers, I often use a reverse version of Michael’s list to help explain what is a unit test. So here’s the same list with a positive spin:

A test is a unit test if :

  • It doesn’t talk to the database
  • It doesn’t communicates across the network
  • It doesn’t touch the file system
  • It can be run at the same time as any of your other unit tests
  • You don’t have to do special things to your environment (such as editing config files) to run it.
Of course there are more qualities. Think of this as a list of traits as necessary but not sufficient for something to be a unit test.

blog comments powered by Disqus