3 ms·
Did you ever actually refactor code with a significant test suite written under heavy mocking? The mocking assumptions generally end up re-creating the behavio
by VHRanger 6y ago
Did you ever actually refactor code with a significant test suite written under heavy mocking?
The mocking assumptions generally end up re-creating the behavior creating the ossification. Lots of tests simply mock 3 systems to test that the method calls the 3 mocked systems with the proper API -- in effect testing nothing, while baking in lower level assumptions into tests for people refactoring what actually matters.
You might personally be a wizard at designing code to be beautifully mocked, but I've come across a lot of it and most has a higher cost (in hampering refactoring, reducing readability) than benefit.
- _pius 6y agoDid you ever actually refactor code with a significant test suite written under heavy mocking? I have. The assumptions you make in your code are there whether you test them or not. Better to make them explicit. This is why TDD can be useful as a design tool. Bad designs are incredibly annoying to test. :) For example if you have to mock 3 other things every time you test a unit, it may be a good sign that you should reconsider your design not delete all your tests.
- monkpit 6y agoIt sounds like your argument is “software that was designed to be testable is easy to test and refactor”. I think a lot of the gripes in the thread are coming from folks who are in the situation where it’s too late to (practically) add that feature to the codebase.