One of the key problems with integration testing is figuring out what to do with your data. If you mock out your database, it's not exactly an integration test. But if you run multiple tests and your database gets out of sync somehow, tests can erroneously fail. In this article on LosTechies, Jimmy Bogard discusses the art of isolating the database while doing integration testing.
"So what are some ways to isolate databases in integration tests? Let’s first set some guiding principles:
- Developers should be using isolated databases for development and testing
- Tests should be isolated in the data they create and query from other tests
"If I want reliable tests, I need to make sure that we’re not employing any sort of shared database amongst our developers and that one test’s data is completely isolated from other tests"
Read the full article: Isolating database data in integration tests