Replies: 1 comment
-
Hi @gsabran, the library buckets dependencies on a per-test basis and so there should be no bleeding out between tests running in parallel. However, you do have to use the @Suite(.dependencies)
struct MySuite {
// …
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My dependencies behave like shared singleton, and outside of tests/previews they are never changed. Probably pretty common.
When running tests in parallel, I found that I often have to convert my code to set the dependency during initialization and keep a reference to it, instead of using the
@Dependency
property wrapper that will read the current value on access. The issue with the later is that when tests are running in parallel, the current shared value for a given class might not be the one it had when initialized anymore.For my use case, I would always prefer for the dependency to be set during initialization, instead of on access. This would solve most of my testing issues. I was wondering if this is something that could be supported without breaking existing apis.
ie I often have to convert this
to:
The later works, but adds some amount of boilerplate I'd love to avoid. Each time I go add it this is after spending time debugging failing / flakey tests that the later behavior would have most often avoided. So I'd like to be able to make this a default.
Beta Was this translation helpful? Give feedback.
All reactions