How Tests Support Refactoring - The Code Whisperer

I have witnessed programmers express annoyance about how tests seem to interfere with changing production code. A discussion on this topic led here:


This is a companion discussion topic for the original entry at https://blog.thecodewhisperer.com/permalink/how-tests-support-refactoring

Just give your unit tests a bigger scope (eg. make them as sociable as possible) and avoid mocking.

See this excellent talk by myself ;);

This strategy helps, but it is not the only way, not always the best way, and can lead to new problems.

We will always have people who have the impulse to react to this feedback in each way: some who immediately want to write bigger tests and some who immediately want to refactor more-aggressively. I am now convinced that teams would benefit from having a balance of people who lean in both directions and the resulting disagreements, as long as those remain civil.