Wednesday, June 15, 2016

Are Unit Test Frameworks Really That Great?


Unit test frameworks seem great. Modern test utilities like Mokito and PowerMokito give you the ability to test any part of your code, no matter how hard they are to get to, and no matter how inflexible and poorly designed the code is.

I can test my private methods! This is great!!

Or is it?

The public interface for that class changed. The functionality is only a little different. But the implementation is bunk, and it has to be redone!

Which would be more work?

A -- update unit tests that verify only the functionality of the public interface (which only has minor changes)?

B -- rewrite the unit tests almost from scratch, because they are tied inextricably to the private implementation and will all completely fail after the production code is rewritten?

The answer should be obvious, but if not...

A complete rewrite is more work, even for test code.

No comments: