diff --git a/src/content/daily-email/2023-11-14.md b/src/content/daily-email/2023-11-14.md new file mode 100644 index 00000000..f9b9b8e0 --- /dev/null +++ b/src/content/daily-email/2023-11-14.md @@ -0,0 +1,26 @@ +--- +title: > + Why I prefer integration tests to unit tests +pubDate: 2023-11-14 +permalink: > + archive/2023/11/14/why-i-prefer-integration-tests-to-unit-tests +tags: + - software-development + - automated-testing + - test-driven-development + - mocking +--- + +With unit tests, you need to mock __everything__. + +If what you're testing has a dependency, you need to create and use a mock version. + +If the mock has its own dependencies, you need to mock those, too. + +I've written unit tests with mocks and accidentally only tested the mocks instead of the functionality I intended. + +## Here's the thing + +With integration tests, you can use and test the real dependencies. + +Whilst they may be slightly slower to run, I prefer the simpler setup, less need for mocks, and knowing the real services work - not just the mocked versions.