-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The class org.junit.jupiter.api.AssertionUtils and its methods should be public #2967
Comments
Having and keeping internal utility classes/methods concealed was a design decision made on purpose. I don't think that will "make As you noted, module
Perhaps something like this might be doable for Jupiter's low-level assertion utilities as well? 🤔 |
Which of them are you using? |
|
👍 There is some logic in how values are formatted and printed which is inaccessible when building own assertions. To have the same logic applied it would be good to have some way to use these methods. But this could be done in a different way than exposing the utils. For example by exposing another method or exception that later is passing things through these utils. |
Team Decision: Explore adding an API to make failure message formatting publicly accessible. |
@marcphilipp Looks good to me. Thanks for quickly adding this new class, and for integrating it already in the upcoming release! |
@twwwt Thanks for the feedback! Reopening the issue since the corresponding PR is not yet merged. |
For our own purposes, we have implemented additional assertion methods (
assert...(...)
) in a test utility class. Motivated by reusing existing functionality, this class makes use of the static methods oforg.junit.jupiter.api.AssertionUtils
; mostly for throwing assertion errors and for formatting error messages.AssertionUtils
and most of its methods, however, are package-protected. In order to make them visible to our class, we have put it in the same packageorg.junit.jupiter.api
. Now that we are using Java's module system, we can no longer proceed this way since Java's module system does not allow to have the same package in more than one module. Therefore I would like to propose to makeorg.junit.jupiter.api.AssertionUtils
public as well as all its methods that are currently package-protected.Note that there are a couple of other utility classes in
org.junit.platform.commons.util
that are already public; thoughorg.junit.jupiter.api.AssertionUtils
is injunit-jupiter-api
whileorg.junit.platform.commons.util
is injunit-platform-commons
. I'm not necessarily proposing to also relocateAssertionUtils
intojunit-platform-commons
: But if that makes sense, it seems better.junit-platform-commons
is already a compile dependency ofjunit-jupiter-api
.Deliverables
The text was updated successfully, but these errors were encountered: