News for hackers. Stuff that matters.
Re:Most Unit Testing Is Waste (2014) [pdf] by war1025 on Friday June 28, 2019 @11:18PM (#20310619)
Some of our older tests at work are an absolute nightmare to deal with. We went through a phase where we basically just mocked everything non-trivial and ended up with a rewording of the code itself. Any time you make a change to that code, even if it still behaves exactly the same from a user point of view, the tests blow up into pieces and you end up having to rewrite or throw out most of them.

We moved to a behavior-focused testing style, and it has been much more robust to non-functional changes and refactorings in the code.

Re:Most Unit Testing Is Waste (2014) [pdf] by MetalGuru on Saturday June 29, 2019 @01:20AM (#20310935)
What do you mean by behavior-focused testing style?
Re:Most Unit Testing Is Waste (2014) [pdf] by kd5bjo on Saturday June 29, 2019 @03:01AM (#20311202)
Presumably, testing that the API of each unit produces the desired result without consideration for how it accomplishes that internally. If it relies on some other component internally but never exposes that in the public API, it’s reasonable to consider that component as part of the unit under test and not try to mock it out.
Re:Most Unit Testing Is Waste (2014) [pdf] by falsedan on Saturday June 29, 2019 @05:07AM (#20311578)
And if you do need a mock (for something with hard-to-undo side effects), you set it up with stub response & canned data in the test fixture, and never assert anything against it in the test.

Part of the problem is that most test fake libraries support mocks (usually they even have it in the name), those mocks have complex “verify the 3rd call was function doDoAction with parameter (‘yes’, ‘really’)” and then people think that full-blown mocks are the only way to guarantee 100% correctness.