October 2019
Intermediate to advanced
358 pages
8h 22m
English
We mentioned that DataCase uses some aliases, imports, and macros to give us the functionality our tests need. One of the features that file provides is the Ecto Sandbox. The role of the sandbox is to undo all changes we have done to the database during our tests. These database transaction rollbacks give us test isolation.
The way the sandbox operates is quite efficient too: instead of deleting all of the data once the suite finishes, which would be expensive, it just wraps each test in a transaction. Once the test is done, the transaction is rolled back and everything behaves as if the data was never there.
While a database sandbox is commonplace in many web frameworks or database libraries, ...
Read now
Unlock full access