daily-email: add 2023-11-14
Why I prefer integration tests to unit tests
This commit is contained in:
parent
989c5996a5
commit
6417b01d61
26
src/content/daily-email/2023-11-14.md
Normal file
26
src/content/daily-email/2023-11-14.md
Normal file
|
@ -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.
|
Loading…
Reference in a new issue