attach something if assertion failed #2733
Answered
by
scordio
NewbieProger
asked this question in
Q&A
-
Hello. I have assertion:
I need to attach smth if assertiong falied. something like this:
|
Beta Was this translation helpful? Give feedback.
Answered by
scordio
Aug 5, 2022
Replies: 1 comment
-
Hard assertions do not really have a callback mechanism, but soft assertions might serve your purpose. There are two options:
Both ways allow you to provide your own logic to be executed with each assertion error. Examples of both solutions are in the AssertJ documentation. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
NewbieProger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hard assertions do not really have a callback mechanism, but soft assertions might serve your purpose.
There are two options:
setAfterAssertionErrorCollected
on a customSoftAssertions
instance, providing your ownAfterAssertionErrorCollected
implementation (can be a lambda).AbstractSoftAssertions
and overrrideonAssertionErrorCollected
.Both ways allow you to provide your own logic to be executed with each assertion error.
Examples of both solutions are in the AssertJ documentation.