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?
The tooling at the moment is not great, but improving:
@Rule
s (e.g., ExpectedException
) as of v2018.2.ExpectedException
s, @Test(expected = …)
) to assertThrows
, 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 Parameterized
tests, or rules other than ExpectedException
.
Here is an example Error Prone configuration:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<showWarnings>true</showWarnings>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<source>${java.compiler.source}</source>
<target>${java.compiler.target}</target>
<compilerArgs>
<arg>-XepPatchChecks:TryFailRefactoring,ExpectedExceptionRefactoring,TestExceptionRefactoring</arg>
<arg>-XepPatchLocation:${project.basedir}</arg>
</compilerArgs>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With