Add TestAspects afterFailure and afterSuccess #8588
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.
Currently there is no way (that I'm aware of) to react to a test failing or succeeding in zio-test.
I've created TestAspects for this use case that I think might be helpful to others too.
My use case for these is making sure that specification files are only generated once a ZIOSpec has verified that the application indeed adheres to the desired spec, thus avoiding generating a file that does not match application behaviour.
Ideally, there'd also be a similar TestAspect for a Spec instead of single tests to only execute an effect once a set of tests (e.g. all of a ZIOSpec), but I have not found a way to evaluate a Spec and retrieve it's result (or failure) from within an aspect; if there are any I'd look into adding such an aspect as well.