I use MySQL in my system but the advice should be applicable to Postgres as well: keep your test database in a ramdisk. By moving my MySQL to ramdisk I got almost a tenfold improvement when running tests on a build server. Not so much (but also significant) improvement when running tests on my development machine.
Don't test with SQLite when you use Postgres in Production
11–20 of 110 posts
Re: Don't test with SQLite when you use Postgres in Production
#12Re: Don't test with SQLite when you use Postgres in Production
#13He claims SQLite doesn't have CTE's but I believe it actually does.
Re: Don't test with SQLite when you use Postgres in Production
#14On the mocking thing: I thought the point of that was to completely avoid DB calls for speed when testing other logic layers, so even a fast in-memory DB isn't needed and anything (i.e. just some code that manufactures a response object) that produces a result set in the right format will do? In that case even using an in-memory DB is less efficient than the other option so is at best a "half optimisation". Am I missing a point here?
Re: Don't test with SQLite when you use Postgres in Production
#15Because it's so much easier and it still lets me test 95% of my code. And the alternative is not testing at all because there is limited time for testing and setting up a proper database for this is so much more trouble.
The choices are not good test vs bad test. They are test-with-issues vs. no test.
(Obviously you have to do SOME testing with the real DB but this article is talking about unit tests (or related))
Re: Don't test with SQLite when you use Postgres in Production
#16Re: Don't test with SQLite when you use Postgres in Production
#17- All the concerns listed in this article are addressed by ORMs.
- SQLite supports CTE[1] (subqueries).
- It's safer to use the exact same setup in development and production, but it's slower for applications with many tests. It's a trade-off and that's all there is to say.
[1] http://stackoverflow.com/questions/21819183/how-to-use-ctes-...
Re: Don't test with SQLite when you use Postgres in Production
#18I use MySQL in my system but the advice should be applicable to Postgres as well: keep your test database in a ramdisk. By moving my MySQL to ramdisk I got almost a tenfold improvement when running tests on a build server. Not so much (but also significant) improvement when running tests on my development machine.
Why do you think there was a difference between tests on a build server and on your development machine? Was it just a case of the build server being configured for performance?
Re: Don't test with SQLite when you use Postgres in Production
#19What about if you're using an ORM, wouldn't that fix the issues mentioned?
Re: Don't test with SQLite when you use Postgres in Production
#20If you're talking integration tests, then of course you should use an environment as close to production as possible.