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.
This PR adds the ability to perform multiple assertions in a block without the test stopping on the first failed assertion. The
verifyAll
function takes a lambda, and any assertion failures inside the block will be gathered, then thrown when the block exits.Many other testing framework have some version of this functionality:
The implementation works by changing the
should*
dsl functions to send their failures to anErrorCollector
, which will gather the errors when inside averifyAll
block, or throw the error immediately otherwise. The collected errors are held in thread-local storage to prevent race conditions in the unlikely case that multiple threads invokeverifyAll
concurrently.Existing assertion functions that take a lambda often rely on throwing an exception for control flow, and so will continue to throw immediately instead of collecting their errors. This includes
eventually
,shouldThrow*
,shouldTimeout
, and property and table testing.