Random state testing #1649
-
Hi all. I have a feature that calculates the position of some elements in the screen by using a Random algorithm. So, in order to test the state, it is imposible for me to determine what the position will be for every run. How I can use a TestStore to make a test that can skip that property? It is possible? Thanks in advance for the answers. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hey @joelCHonor, did you see the "non-exhaustive" test store feature that was released recently? It allows you to opt out of exhaustivity for a particular test: let store = TestStore(...)
store.exhaustivity = .off(showSkippedAssertions: true)
store.send(.tap) {
$0.count = 1
// No need to assert on fields that were changed randomly
} Alternatively, you could control your dependency on randomness. You could have a |
Beta Was this translation helpful? Give feedback.
-
Guys thank you both of you for answering so fast. @mbrandonw I tried the |
Beta Was this translation helpful? Give feedback.
Hey @joelCHonor, did you see the "non-exhaustive" test store feature that was released recently? It allows you to opt out of exhaustivity for a particular test:
Alternatively, you could control your dependency on randomness. You could have a
@Dependency(\.random)
in your feature that in tests just returns a constant value.