3 ms·
I've grown to rely much more heavily on integration level testing for that exact reason. One still has to mock certain dependencies such as 3rd party APIs but i
by barbazoo 5y ago
I've grown to rely much more heavily on integration level testing for that exact reason. One still has to mock certain dependencies such as 3rd party APIs but it's far more reusable to figure out how to do that imo than figuring out how to mock every single class you're interacting with.
- kqr 5y agoNow I'm feeling dumb but... why would you ever need to mock every single class you're interacting with? I'm often test-driving stuff with unit level tests and the only times I have to mock collaborators are when the collaborators are - third party services, - badly designed, or - not built yet. This has nothing to do with unit/integration level testing.
- barbazoo 5y agoI was thinking of access to files, database, http endpoints, etc that need to be mocked if the unit your testing has dependencies that do those things. With integration tests my expectation is that we're using real dependencies just fake data which is often easier to set up.
- kqr 5y agoIf anywhere close to 100 % of your classes accesses files, database, http endpoints etc. I still think you have badly designed code. (And if that code had been test driven, maybe it would have had fewer classes with external dependencies.)