-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Cannot write code that deals with assumption violation without using internal API #390
Comments
This is an old issue, but still quite valid. Unfortunately, I don't really want to create a copy of AssumptionViolatedException in a non-internal package. I actually think the answer to this is to stop using package names to indicate intent of visibility or stability: create @internal and @experimental annotations, which we can remove easily in order to "promote" these hidden APIs to full public. The question, then, would be javadoc generation, and how to document that "internal" doesn't mean the same thing it once did. |
For I could be convinced to create |
To clarify: I think the low-hanging fruit here is to create a subclass of |
The external package subclass is a good idea. We should be sure, however, to also expose external API that allows an extender to know whether an exception is an assumption failure, since Perhaps something like AssumptionViolatedException.isAssumptionViolation(Throwable t)? |
@dsaff If you are talking about code outside of JUnit itself that is catching Or are you talking about code outside of JUnit itself that is throwing |
@kcooney, I'm thinking about someone writing a new Rule that wants to be a good citizen and handle assumption failures. She'd be tempted to do this:
But if this Rule gets re-used on a project with an old core JUnit (or mixed together with a Rule that threw caution to the wind, and directly instantiates internal.AssumptionViolatedException), then the catch won't fire if external extends internal (which does, in general, seem like the right idea), so we should add some other way of determining whether an exception is an assumption violation, regardless of which version of JUnit threw it. Make sense? |
@dsaff if that rule is used in a project that used JUnit 4.11 or earlier, it would fail spectacularly because I can't imagine code throwing |
Good point about JUnit lib. Not sure what late-night state of mind produced my confusion. |
Fixed in #818 |
Since AssumptionViolatedException is internal API, you cannot write a rule, runner, etc. that react differently to assumption violations than other exceptions without crossing the boundary into internal API.
The text was updated successfully, but these errors were encountered: