Unit testing bad
November 13, 2007 3 Comments
More on unit testing and TDD – it’s good and it’s got momentum. As Steven Feuerstein commented on a previous post of mine, “deficient testing is generally an ongoing worldwide crisis in the software industry”. And no more so than in the database, I’d warrant.
However, whatever tier we’re testing, with whatever technology, I’m uncomfortable with unit testing dictating which methods/procedures/etc are public and which are private within a class/package/etc. Taking it to the extreme, you’re almost saying that unit testing is more important than security and code access control.
I believe that one possible approach in Java is to circumvent the access control using Reflection. Not something I know much about.
But there is no such mechanism in the database.
One approach might be to use conditional compilation. However, in general, my feelings are that conditional compilation solves a nonexistent problem. I don’t like the idea of testing a piece of code that might have conditional compilation clause changing what and how it does something between Dev, Test and Prod environments or between different versions.
In general, if you can refactor a routine into a packaged function or procedure then that makes sense and it makes sense to expose it as a testable unit.
But all this does not make private procedures and functions redundant. No way.