4 ms·
For database testing you'd mock[1] the connection in some way. I've done it before by swapping in an SQLite database with some sample data. [1] http://en.wikip
by 286c8cb04bda 14y ago
For database testing you'd mock[1] the connection in some way. I've done it before by swapping in an SQLite database with some sample data.
[1] http://en.wikipedia.org/wiki/Mock_object http://en.wikipedia.org/wiki/Mock_object
- pyre 14y agoHow is swapping in a SQLite database any different than separating development / testing / production databases? At work we use a test database that is schema-only. All tests populate the data during setup, and rollback on tear down. The fear of running unit tests in production is that someone screwed up the testing configuration and your database writes are no longer happening on a mocked SQLite connection, but hitting the live database. Oops!
- 286c8cb04bda 14y ago> How is swapping in a SQLite database any different than separating development / testing / production databases? At work we use a test database that is schema-only. All tests populate the data during setup, and rollback on tear down. It's better for me because it works when I'm on an airplane, that's all. If you do all of your development where the test database is accessible, then there's little to no benefit. > The fear of running unit tests in production is that someone screwed up the testing configuration and your database writes are no longer happening on a mocked SQLite connection, but hitting the live database. Oops! I Agree. Unit tests should never be run in or near production systems. The whole purpose of the tests is predicated on the assumption that your code is broken. Do you really want to bring broken code near customer data?