May 4, 2014
I see a lot of people suggesting to use SQLite — or some other light database system — for testing because it’s faster than what they use in production and hence end-to-end tests will run faster. Not a very bright idea.
Why do you write tests in the first place? I bet you do that to be sure that the app works the way it’s supposed to. It’s your safety net. It’s the source of your confidence. It’s what makes you sleep well at night.
Now, why would you give up that confidence just to make your tests run faster?
Since different database systems have their own quirks, the fact that your tests pass on one system doesn’t mean the application will work on another. It’s like testing your app on Windows to be sure it works on Linux. Doesn’t make much sense, does it?
Do you really care if your tests are fast if they don’t actually prove the application really works? On any given day, I’ll choose slow tests that prove that my app works instead of fast tests that don’t prove anything. I hope that after reading this post, you will, too.