3 ms·
Now 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
by kqr 5y ago
Now 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.)