Replies: 1 comment 18 replies
-
Assuming you are creating a custom assertion class, you might want to extend
They're not intended to be used outside AssertJ and you would get a failure in both JPMS and OSGi world if you try to do that. Could you provide some more context on what you're trying to achieve? Would you have the chance to sketch the custom assertion you are trying to design in a GitHub project, together with the type you are targeting? |
Beta Was this translation helpful? Give feedback.
-
The examples on the custom assertions docs implement the assertion logic directly, but for more complex checks it would be nice to reuse the assertions that AssertJ already provides and I'm not sure how to that properly.
First of all, I'm not sure if classes in the
internal
package (e.g.Iterables.instance()
orStrings.instance()
) are intended to use outside AssertJ and could help somehow.Other than that after looking around I think something like this should be done to respect the error, description, etc. if set by the user:
I also looked into the
withAssertionState
method, but although it partly fits the bill and would fill even more information depending on the assertion class, it's currently package private and there would still be the need to check somehow if the user set their own values or appropriate defaults should be used (e.g."Default message"
vsgetWritableAssertionInfo().overridingErrorMessage()
above).Would it be possible to add something to more easily support this? Or is there already a recommended way or reusing assertions that could be documented? Any guidance will be appreciated.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions