3 ms·
The reason to mock out IO is not that much about the performance, but isolation. It's annoying to have to deal with setting up database instances, users, permi
by dpc_pw 6y ago
The reason to mock out IO is not that much about the performance, but isolation. It's annoying to have to deal with setting up database instances, users, permissions and what not, just to run an otherwise standalone test. Also annoying when two test suites running in parallel conflict (though it can be avoided). If you use sqlite, it's much easier since it's all just working on standalone file.
> I disagree - I always test a real database, never mock it.
I always put an interface between the IO part and rest of the code, so I can either mock it or not. Ideally I would have a separate tests making sure that the real-IO implementation of the interface works, and not use in my normal test that are exercising logic. But it is indeed a lot of additional work, so I'm cutting the corners and let the test run against a real db implementation, only wrapping it in things like injecting faults etc.