Replies: 2 comments 2 replies
-
I was wondering the same and playing around with it I get crashes with the latest release and flaky test results when using the swift6 branch version. Sometimes I do get the correct mock instance in the test and sometimes it is a different one from the one that is @injected in the subject under test. Seems like the approach to register the mocks .cached and resetting the container before each test does not work in Swift Testing. |
Beta Was this translation helpful? Give feedback.
-
If you inject a specific container instance into your view models or services, then you can build and inject a separate container for each set of tests so that parallel testing works. If you access Container.shared or use one of the @injected property wrappers that depend on Container.shared, then your tests need to be serialized. This issue isn't specific to Factor or Resolver, and in fact impacts other scenarios like using a URLProtocol on URLSession.shared, or testing any code that depends on a global or statically shared variable. https://www.swiftwithvincent.com/blog/how-to-mock-any-network-call-with-urlprotocol |
Beta Was this translation helpful? Give feedback.
-
I'm wondering how injection is going to work with parallel tests in the new Swift testing framework.
If I have two different tests which want to inject different values to the same container object they can't really run in parallel
Beta Was this translation helpful? Give feedback.
All reactions