5 ms·
Testing with mocks is generally a bad idea; instead, one should just test using the same dependencies that are used in production (after testing those dependenc
by devit 7y ago
Testing with mocks is generally a bad idea; instead, one should just test using the same dependencies that are used in production (after testing those dependencies, if also part of the project).
This avoids having to introduce the extra interface, having to code the mock, sometimes having to change the mock or tests when changing the code and also lets you catch bugs in the dependencies that the tests on the dependency itself missed and that would otherwise show up in production.
One might have to do some work to partially replicate the production setup in testing and making it fast to start and run, but that's usually less work and gives a much better result.
- ludjer 7y agoThat is more integration tests. Unit tests should target logic more then dependencies/integration.