Change "EventuallyWithT" condition acceptance to no-errors raised #1
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.
Summary
This change updates the
EventuallyWithT
assertion variants (regular, formatted, requirement) to consider a condition as "met" if no assertion errors were raised in a tick.This allows to write easier conditions which simply contain assertions, without needing to return a bool. The equivalent of a condition returning true in the previous implementation would be a a condition with a single "assert.True(..)" call.
Changes
EventuallyWithT
variants to consider a condition as "met" if the mocked T (assert.CollectT
) has no errors.Motivation
It's easier to write conditions that only use assertions than conditions that both assert and also need to evaluate the condition result, as the result is often dependent on whether any of the assertions failed. For instance, if an assertion failed, but the condition function returns
true
, the collection assertions will not fail the test.Example usage (if applicable)
Related issues
Related to stretchr#902 and stretchr#1264