4 ms·
A good compromise is you write an in-memory version of the dependency and the real version. You write a comprehensive test of integration tests against the rea
by UK-Al05 7y ago
A good compromise is you write an in-memory version of the dependency and the real version.
You write a comprehensive test of integration tests against the real object.
You then set it up so those same tests can run both the in-memory and real version.
Any differences should show up for the interactions you have specified, and tests should fail.
You can write sociable unit tests against the in-memory version, knowing it matches the same behaviour as closely as you have specified in the tests.
- mumblemumble 7y agoThat's what I typically do when I must. I find it yields much more readable tests than mocking does, and they're less likely to accidentally become tautological. That said, discrepancies can still sink in, so I think it's best to also have some baseline level of tests that run against the real dependency, even if they're typically only run overnight on the CI server.