3 ms·
> this is IMO outdated terminology, and in my experience not modern practice. It's super easy now-days to swap in a local lightweight database like sqlite which
by GordonS 6y ago
> this is IMO outdated terminology, and in my experience not modern practice. It's super easy now-days to swap in a local lightweight database like sqlite which is 99.9% compatible with your production database, and use this for even tiny unit tests.
I actually see it as more "modern" to use an actual database.
I've been around long enough to have seen trends going from database -> mocks -> fake -> back to databases again!
Mocking is fine for some cases, as are fakes (e.g. lightweight SQLite wrapper you mention), but for anything non-trivial, such solutions often have "blind spots" - such as foreign keys, or unsupported data types. At the same time Docker was becoming a thing, I (and others) were growing tired of seeing issues related to these limitations.
At some point, it pays to have integration tests that just hit a real database. And with Docker, you can do that trivially - it takes only a few seconds to spin up and populate a fresh Postgres instance. I haven't looked back since.
- jerven 6y agohttps://www.testcontainers.org/modules/databases/ https://www.testcontainers.org/modules/databases/ is brilliant for this in the JVM world.