I’m working through the Information Security/Quality Assurance curriculum and have some questions about best practices regarding unit/functional tests.
It seems the paradigm is that each test should be self-contained and not rely on any previous test. In most of the projects, these tests cover interacting with a database.
In order for a GET function interacting with a database to be properly tested, a document must already exist in the database. However, the project assignments split up the tests (e.g. a set of GET tests, a set of POST tests, etc).
Should each individual test perform multiple database actions (i.e. to test a GET function, first perform a POST, then a GET, then a DELETE)? It seems redundant to have a GET test and then a separate POST test and a separate DELETE test if the first GET test requires all 3 functions in order to be self-contained and not rely on any previous test.
Right now I’m trying to keep the tests separate to complete the assignment and so the tests are extremely redundant; what is the best practice for a real world situation?