-
-
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
Adds fail() methods that pass Throwables - closes #656. #661
Adds fail() methods that pass Throwables - closes #656. #661
Conversation
@@ -36,6 +36,14 @@ static void fail(String message) { | |||
fail(() -> message); | |||
} | |||
|
|||
static void fail(String message, Throwable cause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite a new use of fail
to me, so I think the method would be better named failWithCause
or something along those lines to help prevent confusion.
throw new AssertionFailedError(message, cause); | ||
} | ||
|
||
static void fail(Throwable cause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
* <em>Fails</em> a test with the given failure {@code message} as well | ||
* as the underlying {@code cause}. | ||
*/ | ||
public static void fail(String message, Throwable cause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
/** | ||
* <em>Fails</em> a test with the given underlying {@code cause}. | ||
*/ | ||
public static void fail(Throwable cause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
@jbduncan I'm open to whatever names the group feels comfortable with ... there was quite a bit of discussion on issue #655 before I created #656. My preference was to make a conditional assertion called something like So ... what does the team want? |
@@ -80,6 +80,7 @@ on GitHub. | |||
* `Assertions.assertThrows()` now uses canonical names for exception types when | |||
generating assertion failure messages. | |||
* `TestInstancePostProcessors` registered on test methods are now invoked. | |||
* There are two new signatures `Assertions.fail` - `Assertions.fail(String message, Throwable cause)` and `Assertions.fail(Throwable cause)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please manually wrap lines with more than 100 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've amended the commit which updated the release notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
The core team is going to meet this Wednesday. We'll discuss it then and let you know. |
0bbf74e
to
42757a9
Compare
Overview
This PR adds two additional signatures for the
Assertions.fail()
methods:Assertions.fail(String message, Throwable cause)
Assertions.fail(Throwable cause)
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
Method preconditions are checked and documented in the method's Javadoc@API
annotationsUser Guide andRelease Notes