-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Fluent expectations for ExpectedException #1245
Conversation
I think we decided to not make any more changes to See #1199 |
Few things. Firstly, using |
And if you want to check the cause, you can use In contrast, I conceed your point about Android (I have been raising the same concerns about JUnit Lambda's use of Java 8 APIs). I'll leave it up to @marcphilipp to decide |
@kcooney I'm interested in knowing, what's the incorrect usage? It seems quite straight forward. An interesting alternative for lambda can be found in AssertJ: Also, more powerful in terms on what to test on the exception. |
@pablisco The |
We considered an approch similar to AssertJ, but 1) creating a good DSL is challenging, 2) not everyone likes DSLs and 3) people that do like DSLs most likely already use an assertion DSL (like Fest or Truth). |
Even though the use of
|
Fluent expectations for ExpectedException
Is maintaining bytecode compatibility a goal for JUnit? This will break test classes compiled against ExpectedException from 4.12 to work with 4.13 or newer (source). |
@PhilippWendler I don't think we have given that much thought. We do try to maintain source code compatibility, but we have unintentionally broken source code compatibility in some of our prior releases. Binary compatibility is usually only an issue with third-party libraries. I don't know how likely it is for third-party libraries to use this class. |
This small PR will allow for the
ExpectedException
rule to be used in a more fluent manner.May need updating on https://github.com/pablisco/hamcrest-junit too