Setting Up Sandbox Mode
Our database keeps state, and right now this test is leaving new rows in the database. In the short run, it’s very unlikely to create a problem because we’re using a new, random string every time we run the test. In the long run, having persistent data between test runs increases the likelihood of having test failures due to unforeseen data collisions. If the same random string did happen to be picked in different test runs, the test would fail on the first inserted user, which was supposed to be part of the setup.
Working against your database in tests is one of the most common places where leftover state changes can cause problems. We managed to avoid issues with our test on the unique constraint by using randomized ...
Get Testing Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.