Description
JUnit 5 has a ton of neat features that make writing tests easier and more expressive. It provides a compatibility layer for JUnit 4 and 3, so we should be able to migrate pretty easily there.
In order to migrate v4 tests to v5, we'll need to support the following:
- LoggerContextRule should have an equivalent ParameterResolver extension which injects a LoggerContext parameter among other types. (This class should remain for JUnit 4 users, and an abstraction might help in making something equivalent available for JMH tests as well).
- This is currently implemented via the LoggerContextSource annotation.
- Test categories should be converted to tags.
- @Ignore should be replaced with @Disabled or appropriate conditional disabled annotations (also useful for replacing assumeThat() tests).
- IntelliJ's convert to JUnit 5 refactoring action does this automatically.
- Hamcrest must be added as an explicit dependency and/or replaced by something better like AssertJ.
- IntelliJ's convert to JUnit 5 refactoring action does this automatically.
- The other test annotations need to be updated to the new ones.
- IntelliJ's convert to JUnit 5 refactoring action does this automatically.
- Parameterized tests can use the new parameters annotations to simplify things a lot.
- TemporaryFolder rule can be replaced with @TempDir parameter injection (experimental feature).
- Other rule usage needs to be converted to use appropriate v5 features or turned into extensions.
Note that this upgrade should be backported to the release-2.x branch after Java 8 is made the baseline there.
Attachments
Issue Links
- links to