Junit4 to assertj
What's changed?
This change enables JUnitAssertXXXToAssertThat recipes to also handle JUnit 4 assertions. Therefore it introduces an abstract superclass that allows to configure JUnit 4 & 5 specific method matchers and a visitor that handles both configurations.
Tests are added for the refactoring of JUnit 4 style assertions. Note that JUnit 4 has mostly matching assertions, but less capabilities in detail:
- No support for message suppliers
- No assertion for instanceOf The tests are reduced by that for JUnit 4.
What's your motivation?
- fixes #672
This is for a migration to JUnit 5 where I want to migrate the assertions before the test classes themselves, because due to extensive use of JUnit 4 rules and parametrized tests the migration has to be done partially manually and changes to the assertions are distracting.
Anything in particular you'd like reviewers to focus on?
The structure of the abstract's class logic and naming.
Performance consideration: When JUnit 4 style is migrated, first the JUnit 5 configuration is tried to be matched.
Checklist
- [X] I've added unit tests to cover both positive and negative cases
- [X] I've read and applied the recipe conventions and best practices
- [X] I've used the IntelliJ IDEA auto-formatter on affected files