-
Notifications
You must be signed in to change notification settings - Fork 72
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 test that generated invalid code #331
Conversation
...st/java/org/openrewrite/java/testing/assertj/JUnitAssertThrowsToAssertExceptionTypeTest.java
Outdated
Show resolved
Hide resolved
Thanks for adding a test to reproduce an issue! Indeed best to not convert such cases if there's no direct replacement in AssertJ. If you add |
I'll push a fix that leaves such a case as is. Shouldn't be too hard to check if the assertThrows appears on the RHS of an assignment. |
A check is added to see if assertThrows appears immediately inside a J.Block.
Instead of blacklisting the case where Also, I am unsure what exactly the code style is, where can I find it? Is the style I used okay? |
Looks like a fine addition to me; thanks for taking the time to think through other limitations as well, and providing a fix.
We typically use the IntelliJ default, sometimes supplemented with I like the changes you've made! My only change is adding the Issue annotation with links here, such that we can refer to this discussion. |
Thanks a lot! While we wait for the for the next release in a week or two you can already use our snapshot versions. |
This PR adds a unit test
assertThrowsAssignment
that generates invalid code. In JUnitassertThrows
returns the exception that is thrown, while in AssertJ there is no way (currently) to obtain the exception that is thrown.The purpose of this PR is check whether it is desired behavior open rewrite generates invalid Java code. A solution would be to skip rewriting cases where
assertThrows
is used as RHS in an assignment, but that would leave JUnit assertions in code bases.