🚀 Do you want to eliminate manual QA regression testing? In this way, you’ll reduce delivery time and reduce regression bugs. On Wed 6th Aug (17:00 - 19:00 CEST), I’m hosting ATDD in Legacy Code Roadmap (Live Workshop). During this workshop you’ll learn:
Why ATDD will reduce software delivery time and reduce regression bugs, replacing manual regression testing
How to introduce ATDD in Legacy Code in an incremental way, while still keeping up with existing feature delivery
How to convince Engineering Managers, Software Engineers and QA Engineers to adopt ATDD in Legacy Code
P.S. If you’re a Paid Member, you’ll receive a 100% discount (see Event Description for instructions on how to redeem your 100% discount).
🌴 I'll be on vacation from next week onwards - 14th July until 2nd Aug. You'll receive my scheduled articles during that time. I'll respond to your comments (and continue Sandbox Project Reviews) after I return.
During this Live Q&A, we compared different test doubles, as well as comparing hand-written test doubles versus using mocking libraries.
Using Mocking Libraries
Many developers use mocking libraries, for example: Mockito (Java), Moq (.NET), Jest (JS/TS), etc. I was using mocking libraries for many years, too.
It’s very appealing to use mocking libraries, because you install the library and can immediately start to use it in your test. It’s also very easy how to setup with mock libraries.
Although there’s no upfront cost to setting up test doubles with mocking libraries (since no separate class is required), the issue lies in the ongoing recurring cost: for each test, we must create and set up the mock. Let’s see the impact:
Tests have more lines (due to mock setup), which means more reading time, hence increasing maintenance costs.
Tests are coupled to implementation, because we have to know exactly which methods will be called for each dependency; consequently, if a dependency’s interface changes (e.g., parameters change, or we need to call another method on the dependency), it will cause tests to fail with compile-time error, so we may need to fix hundreds/thousands of tests. This also means higher maintenance costs.
Using hand-coded libraries
You can see examples of hand-coded test doubles in The Little Mocker (Uncle Bob).
I remember when I first saw hand-coded test doubles, I was against the idea. Isn’t it better to use a mocking library instead?!