Hello,
I’ve a problem with unit tests. Whenever I run the unit tests individually, they pass. However, if I run them altogether, some fail. Since the tests are based on shared data (Database), I know this may be the problem.
In order to solve this, I clear the database on setup function in each test. Yet, this doesn’t fix the issue.
So I assume the unit tests work in parallel, which leads to race condition (so some fail & some pass).
My questions are
- how unit test order works?
- Can I force unit tests to run the tests sequentially? Can I force it not to move to the next test until the current test is done?
- What about setup & teardown, do they always work til the end before running test functions?
Thanks! 🙏