Home

News: How to deal with the database when performing integration tests

  1. 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

  2. Unrealistic scenarios[ Go to top ]

    You cannot provide environments in which "one test’s data is completely isolated from other tests" nor can you "Drop and recreate database" or "Delete all data". Those are scenarios that are completely out of touch with everyday life. Just make sure your tests run correctly in a shared environment.  If your tests cannot provide that you have a design problem more than a test problem. 

  3. Seems like an article that had to be posted on theserverside.NET, though the techniques are equally applicable to Java. By the way, what happened to theserverside.net? Seems that site drowned deep under the waters, right?

    Jan