What is Your Experience with Unit Testing in Practice?

//Yes, Virginia, there is a wikipedia.

What I'm asking here is what you've found unit testing to be in your own practice. It would be helpful to know the pros, cons, obstacles to introducing unit testing, flaws in the unit testing process, value gained by unit testing, and so on that the developers here have observed in their day to day practice.

What we're doing:
I work on a web application w/ an Oracle backend. The application has been in production for 8+ years, and there are ongoing enhancement efforts along with the maintenance work.

My development team does Unit Test Scripts (UTS) that aim to walk a developer through the unit test of a given code package. These UTS are 2-20 page Word documents that describe the purpose of the package, the structure, and elaborate on given modules within a package. The UTS concludes with a section that describes an Application Test of the package.

This doesn't sound like unit testing to me. It sounds a lot more like system integration testing w/ a description of the package. It certainly is not automated.

With our UTS practice in its current state, managing/editing/follwing the documents is not a trivial task. And when enhancements or maintenance work to a given package is needed, there are not strict testing procedures put in place to guarantee outputs are satisfactory. Instead, we have this higher level UTS to follow, which does not come close to guaranteeing correct output in various code traces.

Unit test, for me, has been something of a mixed blessing.

I have been in the situation where I must write unit tests for several years now, and I totally see the advantage for a clean and efficient development cycle, however these are some of the issues I have faced.

  • Development may be clean, but when requirements change, you often have to start again at the unit test level. This is, of course, a process issue rather than a TDD one.
  • Testing GUI stuff is nigh on impossible OOTB with most tools
  • There is a large amount of self-discipline required to make sure you use best practice. It is unfortunate but it's very easy to fall away from test-driven to "test-supported" development. By that I mean starting off with the best of intentions, but not sticking to the idea of writing your test first.

In all, though, I am in favour of using unit testing to improve stability, reliability, brevity and general quality of your code. Regression testing is a huge area for unit tests to come into their own, and I sure hope someone else can explain their views on that a little better than I can. :)