In the spirit of this question from JUnit 3 to JUnit 4, are there any list of regular expressions to efficiently migrate from the junit 4 API to the junit 5 API, regardless of the code size?
How to automatically migrate from JUnit 4 to JUnit 5?
2.4k Views Asked by Geoffrey De Smet At
2
There are 2 best solutions below
0
On
With openrewrite you can migrate automagically.
Just run:
mvn org.openrewrite.maven:rewrite-maven-plugin:4.36.0:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:1.28.0 -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit5BestPractices
The tooling at the moment is not great, but improving:
@Rules (e.g.,ExpectedException) as of v2018.2.ExpectedExceptions,@Test(expected = …)) toassertThrows, perfectly augmenting IntelliJ.I recommend the following steps:
assertThrows, enabling the following checks (the example Maven configuration is below):I am not aware of any tools that help to automatically migrate
Parameterizedtests, or rules other thanExpectedException.Here is an example Error Prone configuration: