ZIO Test: make existsIterable assertion more strict #7317
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let's say we've got the following test
If we run it, it fails as expected
However, if we just inline
existsvariable, the test unexpectedly passesI actually faced this corner case and was surprised that my tests pass when they shouldn't.
Proposed solution to this issue is somewhat arbitrary, I don't know if it's better to fail the test with
Result.die(???)using the first found exception or to useResult.succeed(false)and combine errors, but the latter looks more informative to me.So if you apply suggested changes and run the test again, you'll see something like this
Note that this solution still a little bit inconsistent with Scala's
exists, because it will fail event if the exception was thrown after the predicate had been satisfied at least once. It could be fixed, but maybe it's a feature?Also, I believe this PR might break some test somewhere. Don't think it's a big issue, but still needs to be highlighted.