-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestStore expects shared state to be nil when state was set to nil in an independent test showing the same destination #3468
Comments
Hello @dominikmayer, Why it is not working as test suit because you store mock in memory (static let) which has reference What I would suggest you not to store mocks. You will see problem will be solved if you change your mock as below
|
Hi @OguzYuuksel. Thanks for looking into that. Yeah, the first test initiating the shared journal with the default value is probably what's happening here. I just think this is a bug. The Regarding your suggestion. Isn't it almost the same as my definition of
I changed to a |
@dominikmayer |
Ah, right. Missed that. This does solve the issue. Thank you. |
I've been thinking about this more. So I agree that it was probably not smart to use a static constant as it will not be reset during tests. But still: The tests are running serially not in parallel. And the shared variable was set in a test that should be running independent of the other test. So even if the other test initiates the shared variable, shouldn't the explicit setting in the brittle test change that? |
Description
I have the following struct, which is shared in memory:
I then have a feature that can show two other features, one of which contains the shared journal:
And the feature that shows them:
Now when trying to test this setup then the test passes when run on its own but fails when run together with another, independent test, that
a) shows the same destination as will be set in the brittle test and
b) sets the shared journal to
nil
.This happens even when the test are run in
.serialized
mode.Checklist
main
branch of this package.Expected behavior
The test yields the same result whether run independently or as part of a suite.
Actual behavior
Test passes when run independently but not when run as part of a test suite.
Reproducing project
https://github.com/dominikmayer/TCA-Shared-Test-Issue/
The Composable Architecture version information
1.15.2
Destination operating system
macOS 15.0
Xcode version information
Version 16.0 (16A242d)
Swift Compiler version information
The text was updated successfully, but these errors were encountered: