Anthony Trad
Jun 22, 2022

I am well aware that unit testing is testing a unit. And you're right that the system under test should be isolated so you can confidently evaluate and assert your result...

However, mocking is the worst isolation method you can pick. Especially for your infrastructure and database as I mentioned in my article. There are some use cases for Mocking but it should not be the 'go to' for each and every test if there's viable alternatives.

At the end of the day you want your test to be maintanable, and behavior driven. Mocking randomly all your dependencies just to isolate and test is shooting yourself in the foot.

Anthony Trad
Anthony Trad

Written by Anthony Trad

Senior Software Engineer focused on .NET and the Cloud. Reconsidering major principles and patterns, ideas are my own.

Responses (1)