I'm Testing some casual microservice with some business logic and also database, have unit tests but this questions is focused on the integration/component testing that involves DB: how do you manage the DB state to achieve both reasonable performance and simple design? Should I fully isolate each test case, reset the entire DB before starting each test and set the state within the test (e.g. fill records) - I may reach a clean design as each test is autonomous but the performance is really bad. On the other hand, if my tests share the same DB state then they become tightly coupled and steps on its other toes. How would you mitigate this? any related tips/best practices are appreciated.
โ07-17-2020 02:42 AM