-
Notifications
You must be signed in to change notification settings - Fork 85
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
SpringBoot2JUnit4to5Migration: JUnit4 assertions are not correctly updated to JUnit5. #171
Comments
Thanks @josemariavillar, I will have a look |
@josemariavillar, FindMissingTypes is one of the first tools I use when investigating invalid recipe results. The results show several missing types. Looking at your project, I found that it's using Lombok, which is not supported at this time. user = /*~~(type is 'null')~~>*/User.builder().coUser(CTE_CO_USER)
.coUserModification("codification")
.tsModification(timestamp)
.build();
role = /*~~(type is 'null')~~>*/Role.builder().coRole(CTE_CO_ROLE)
.coUserModification("codification")
.tsModification(timestamp)
.build();
userRoleKey = /*~~(type is 'null')~~>*/UserRoleKey.builder().coUser(CTE_CO_USER).coRole(CTE_CO_ROLE)
.build();
userRole = /*~~(type is 'null')~~>*/UserRole.builder()
.id(userRoleKey)
.user(user)
.role(role)
.tsDelete(timestamp)
.coUserModification("codification")
.tsModification(timestamp)
.build();
}
@Test
void assertionsTest() {
/*~~(type is 'null')~~>*/assertNotNull(userRole.getId());
/*~~(type is 'null')~~>*/assertEquals(role, userRole.getRole());
/*~~(type is 'null')~~>*/assertEquals(user, userRole.getUser()); |
requires lombok support openrewrite/rewrite#1297 |
Thanks for the information @pway99. I have a doubt about what you comment, in this specific case what is affecting the lombok library? I don't understand it. |
Regardless, a possible solution while supporting Loombok is to add generically the "import static org.junit.jupiter.api.Assertions.*", thus avoiding any problems. |
Hi @josemariavillar,
Thanks for asking, and please accept my apology for closing this issue with such a brief explanation. In this specific case, the UserRole object uses Lombok annotations, so the As a result the Consequently, the |
Unfortunately, other recipes such as Thanks again for identifying these issues :) |
Good afternoon, I am having problems when applying the SpringBoot2JUnit4to5Migration recipe in the following Test:
When I run the mvn rewrite:dryRun or mvn rewrite:run command I would expect the "import static " to update correctly, instead the import of "assertEquals" and "assertNotNull" are removed and not replaced by their corresponding ones in Junit5 causing it to not compile the code, as can be seen in the following result:
Attached is a test case where the problem can be reproduced and observed: https://github.com/josemariavillar/test_project/tree/assert_to_assertions
The text was updated successfully, but these errors were encountered: