Weird Looking: glass box unit testing can bite me

glass box unit testing can bite me

April 24, 2008 4:32am (2 years, 3 months and 5 days ago)
I’ve seen unit tests where everything touched by the code is mocked out, and the mocks are intelligent in such a way that the tests fail if the mocked methods aren’t all called with correct arguments.  It winds up being nearly a line for line check of the implementation of the code, and is about the most horrible thing I think I’ve ever heard of.

I have basically the same problem with tests against private methods.

Changing implementation details without changing behavior called “refactoring” and is one of the selling points of unit tests.  If a class behaves exactly the same today as it did yesterday, its unit tests shouldn’t suddenly fail, even if someone was mucking around inside it.

If you just want to make sure nobody changes the code, why not get a checksum of the file?  It’ll be a lot less work and have about the same effect.  Ta freakin' da.

And I’m not saying that there aren’t exceptions, just that they are exceptions.

Comments

Apr 24, 2008 10:31am
Indeed

Leave a comment


Accepts BBCode with a few enhancements.