How do you unit test?


I’m doing some research into unit testing and how people generally approach it… the biggest thing I’ve noticed is the wide variety of types of unit tests that exist, and what people’s expectation of what a unit test actually is. I’ve therefore got a very short set of polls below to see what people think. I’m going to leave it open for a month or so to see what the results are.

When answering, please be honest – say what you generally do, not what you think you would like to do if you had the time etc.

Advertisements

6 thoughts on “How do you unit test?

  1. Unit test theory and in practice differs in my experience as does night and day. Tests are usually written as a quaility gate to a public method, e.g., on the business layer, to ensure it does what you want it to in general functional (requirements spec) terms not whether it is 100% fool proof and as a means of triggering alerts in the build process when developers screw something of yours up.

    Time pressures in a commercial / small team environment always cause unit tests to fall into the “nice to have” category in the management view of priorities.

    Unit tests when they are created serve little more than automated functional (I.e. Integration) tests, which is always the first and highest level of testing permitted.

    This all of course is contrary to the ideals of unit testing and TDD which I aspire to; however I speak from an experienced commerial environment where “time is money” and always has to be justified.

    Great blogs btw, keep it up 🙂

    1. Been there, done that re: commercial reality 🙂 And yes, I agree – it’s very difficult to justify the up-front cost of unit testing – particularly when the benefit can be intangible.

    1. Mmmm. There’s only one question of the three that discusses “how” you write tests, and that gives you the option of the failing test first. Although as I write this that’s not the most popular option for that question anyway…

    1. Absolutely. You can click “View Results” under any of the polls to see the current results anyway, but yes, I plan to blog about it in a few weeks (or once I have a reasonable set of data, whichever is first!).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s