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
Add withExceptions
attribute to @ExpectedToFail
#774
Conversation
Adds a new `onExceptions` attribute to `@ExpectedToFail` using which the scope of the extension can be limited to only consider the test as successful if the thrown exception matches one of the given types. Fixes: junit-pioneer#769
This is still in draft state, as I will need to add more documentation and tests. I just wanted to make sure I am not pulling in the wrong direction with this and also check if you already have some input on this. |
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 am undecided if I like this proposal. I really appreciate you taking the initiative and I'm not outright opposed to it, it's just that I worry that despite this being something for a specific use-case, people will be tempted to use it as a "fix-all". Does that make sense?
src/main/java/org/junitpioneer/jupiter/ExpectedToFailExtension.java
Outdated
Show resolved
Hide resolved
src/test/java/org/junitpioneer/jupiter/ExpectedToFailExtensionTests.java
Outdated
Show resolved
Hide resolved
src/main/java/org/junitpioneer/jupiter/ExpectedToFailExtension.java
Outdated
Show resolved
Hide resolved
@Michael1993 I definitely agree with your review comments. I just slapped this together to better convey the idea and to have something concrete to discuss. I understand your concern but I honestly don't quite see the "fix-all" problem. If anything it is JUnit's own My only "concern" as a maintainer would be that the use case is probably rather unusual. But as I think I already mentioned in the issue, JUnit 4's |
Okay, I see your point. Please go ahead with the PR. 😄 |
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 apply spotless and add documentation, if you can. Thank you!
Co-authored-by: Mihály Verhás <misi.verhas@gmail.com>
src/demo/java/org/junitpioneer/jupiter/ExpectedToFailExtensionDemo.java
Outdated
Show resolved
Hide resolved
src/main/java/org/junitpioneer/jupiter/ExpectedToFailExtension.java
Outdated
Show resolved
Hide resolved
src/demo/java/org/junitpioneer/jupiter/ExpectedToFailExtensionDemo.java
Outdated
Show resolved
Hide resolved
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'm happy with current state of the PR. I'd ask you to add yourself to the README as a contributor (but that's not mandatory, only if you want to). Thank you for your patience and hard work!
Thanks a lot for your thoroughness and patience! |
Running full run |
src/main/java/org/junitpioneer/jupiter/ExpectedToFailExtension.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Daniel Kraus <daniel.kraus@mailbox.org>
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.
Hey @knutwannheden, thank you for opening the PR - it looks really good. 😃 A few things could be changed - see below.
But, importantly, can you please open another PR from a feature branch and not main
? Thanks!
Oh, and if you rebase it on the current |
@nipafx Thanks for your review comments. I assume I should wait until the other maintainers have chimed in. In the meantime I've updated the PR with the latest changes from |
I managed to push a small fix on the README order to your Other than that, I will let you take a look at the two remaining comments I made above. |
onExceptions
attribute to @ExpectedToFail
withExceptions
attribute to @ExpectedToFail
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.
If you have the time, please write a few more tests to cover the lines marked in the Sonar analysis.
Co-authored-by: Mihály Verhás <misi.verhas@gmail.com>
@Michael1993 Sorry about the long delays! |
src/main/java/org/junitpioneer/jupiter/ExpectedToFailExtension.java
Outdated
Show resolved
Hide resolved
Proposed commit message:
|
@knutwannheden thanks again! 🙏 |
Adds a new
onExceptions
attribute to@ExpectedToFail
using which the scope of the extension can be limited to only consider the test as successful if the thrown exception matches one of the given types.Fixes: #769