-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Why are we doing this?
The persistence of the "universe" of potential fixture objects in the database throughout the session risks making tests non-independent. For example, a test requiring no instances of a certain model cannot run alongside a test using fixtures, and the Playwright tests (#2408) need a workaround for the non-empty database, changing the fixtures to be function-scoped only for the functional tests.
Always instantiating the full universe of instances also means the dependencies between fixtures are somewhat implicit.
How will we know when it's done?
We have considered and prototyped approaches to the above issues, and raised one or more issues for future work.
What are we doing?
An alternative approach would be to store fixture instances as in-memory objects rather than in the database and save them to the database only when a test needs them. The database could then roll back to an empty state between tests. This might involve changing the scope of most of the fixtures to "function" from "session".
This approach would allow us to invert the hierarchy of the universe so that only required instances are present in the database, not all of them.
The testing coding system databases would likely remain unchanged.
Note that #2430 relies on the universe fixture so we probably want to continue providing that in some form, but not have all tests rely on it. Consider the impact on #2543 and updating that Issue.