F5 is an Ad Hock Test Case - Capture It!

by Paul Kohler 19. November 2008 03:15

Derik Whittaker made a post on the "reasons" why we don't use unit tests in developing our apps. The title captures the result of the "don't use tests" approach well I thought (and what I have noticed over time).

Development Rule:
If you don't develop using unit tests, you will spend a lot of time in the debugger!

The thing to note here is that a unit test does not need to be created TDD style (ooooh, heresy!) No really, you can cut some code and then write a unit test, it is allowed!! I prefer TDD style coding but sometimes (especially in an integration environment) it's just really, really hard! If I get on a roll cutting code to meet a requirement I let that flow. Once the rolling stops you re-evaluate your approach. Simple. I am not at all dogmatic about that sort of thing - everything is influenced by many variables.

On helping others getting into unit testing, I find that thinking of unit tests as "small test harnesses" useful. If you are hitting F5 a lot, write a test harness, use a unit test. In time you will get used to using those tests to help from a regression point of view. A few basic tests can go a long way and setup your regression test base.

Also, just keeping the tests simple. Complicated tests just make people ill and hate "testing" in turn rolling back to the lowest common form of test, F5!

Another thing I have found to really help indirectly is a good refactoring tool, I am a Resharper fan (not a plug!) It keeps your tests in shape. Nothing worse than cutting a bunch of tests only to have them stuffed by a bad refactoring session.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Testing

Powered by BlogEngine.NET 1.4.5.10
Theme by Mads Kristensen