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.
- Oliver
Was this interesting?
About me
I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.