-
Book Overview & Buying
-
Table Of Contents
Rust Web Programming - Third Edition
By :
Unit tests are where the test checks a small unit of code. Testing the data access layer is no exception. However, it is going to be slightly different from our other unit tests. The data access layer is the interface we have with the database. This means that if we mock the database calls, our tests will be close to useless. Because of this, we must coordinate our data access unit tests with the running of the databases. Because there are more moving parts, we must carry out the following steps if we want to unit test our data access layer:
We will start with the teardown SQL command.
Because our tests rely on the interaction of the database, the state of the database can affect the test and make the test flaky, meaning that sometimes they will pass and other times they...