The new framework has been out quite a while, and I thought it might be a good idea to start rolling it out in our codebase.
My only concern is that as we start parallelizing things, we’ll increase the flakiness since we made architectural decisions in the past, like asserting a given output has been printed, which relies on global states.
What if we do the following:
- If the test depends on the global state, we run it serially:
@Test(.serialized) func prepare(food: Food) {
}
- Otherwise, we don’t add the
.serialized
annotation, which means it runs in parallel by default.
It might not be trivial to tell if a piece of logic depends on the global state. Still, as we detect it, we can either turn the test into a parallel test or take the opportunity to propose alternative patterns and move away from the global state (at the cost of compromising the ergonomy of the code with a bit of dependency injection).
Thoughts?