3 ms·
Different unit tests work on different state. One unit test says that if I start from a blank database, add two users, now there are two users. A different unit
by immibis 11mo ago
Different unit tests work on different state. One unit test says that if I start from a blank database, add two users, now there are two users. A different unit test says that if I start from a database with two users, and list the users, I get them.
If you rely on the add-user test running before the list-users test, you introduce bad coupling between tests. However, you could run them all in order in one test - it would be a more complex test. You could then run that on a real database and call it an integration test.
Tests at all levels of complexity are useful. You could run end-to-end tests on a production e-commerce system, from signup to payment with a real credit card and delivery of a real physical product, if you wanted. Backup power systems are tested by shutting off the power a few times a year.
But this article is clearly about unit tests. You shouldn't run unit tests against the production database and you should aim to minimize their dependencies.