Upgrade from JUnit 4 to JUnit 5
We are still using JUnit 4, while JUnit 5 has been available for a long time, and has many nice features that we could benefit from, such as:
-
assertThrows
in the test method, rather than as an annotation, allowing to test multiple throws in a single test. - Nice functionality for parameterized tests.
This will require:
- Project metadata changes (manifests,
.classpath
, etc). - Imports to
org.junit.jupiter.*
instead oforg.unit.*
. - Some changes to our Maven build configuration (surefire).
- Carefully inspecting all assertion statements, due to backward incompatible API changes, such as:
-
org.junit.Assert
:public static void assertEquals(String message, Object expected, Object actual)
-
org.junit.jupiter.api.Assertions
:public static void assertEquals(Object expected, Object actual, String message)
- If you do use
assertEquals
on 3String
-typed arguments, that will still compile with the new import, but will actually mix the arguments.
-
- ...
We do the upgrade in two steps:
-
Upgrade JUnit tests (See !601 (merged)) -
Upgrade JUnit Plug-in tests and setext.texteditor
test, we might need Tycho 4.0 for this (see !601 (comment 1147222)).