3 ms·
I actually agree. I think the point the author is trying to make it that fake can be reused in more places and stay relatively same as the code updates. But I
by slayerjain 3y ago
I actually agree. I think the point the author is trying to make it that fake can be reused in more places and stay relatively same as the code updates.
But I personally think that instead of spending the time to write a fake, its better to just spend the time writing actual integration test with the real dependency (eg: just run the db in docker or something)
or if you don't want to spend that time, then just record the interaction (eg: db calls) and create "throwaway stubs". Use this stubs as long as they are relevant, and then generate new ones as your code grows. Save time "writing" any mocks, and you don't tend to couple too much with your mocks :P
- zackees 3y agoIf running a micro service use sqlalchemy and switch your db to sqlite for testing purposes. There are scalability limits to this but for most cases it works extremely well and is fast.
- commandlinefan 3y ago> just run the db in docker That creates unit tests that take ages to run - and fail surprisingly in hard to debug ways.