65
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 04 May 2024
65 points (98.5% liked)
Ask Experienced Devs
1490 readers
1 users here now
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient
founded 3 years ago
MODERATORS
Our standard practice is to introduce a thin layer in front of any I/O code, so that we can mock/simulate that part in tests.
So, if your database-library has an
insert()-function, you'd introduce a interface/trait with aninsert()-function, which's default implementation just calls that database-library and nothing else. And then in the test, you stick your assertions behind that trait.So, we don't actually test the interaction with outside systems most of the time, because well:
We do usually aim to get integration tests with all outside systems going, too, to ensure that we're not completely off the mark with the behavior that we're simulating, but those are then often reduced to just the happy flow.