Closed averbraeck closed 1 year ago
For @Rule
TemporaryFolder
, a replacement has to be implemented. See https://stackoverflow.com/questions/56613895/how-to-get-rid-of-temporaryfolder-rule-in-junit5 and https://www.baeldung.com/junit-5-temporary-directory
The following code:
@Rule
public TemporaryFolder folder= new TemporaryFolder();
can be replaced with:
@TempDir
private Path folder;
and a statement like:
String temp = this.folder.getRoot().getAbsolutePath();
with
String temp= this.folder.toString();
Upgrade executed. All unit tests pass again.
JUnit 5 has been the new standard for unit tests for quite a while now (since 2017). The big challenge for updating from version 4 to version 5 is that the order of the parameters in the various static
assert
statements such asassertEquals
orassertNull
has changed. Optional arguments such as theString
message were at the front, where optional arguments are typically at the back. JUnit 5 puts these optional arguments at the back, leading to a massive number of changes in the unit test code. The package structure has also changed considerably.JUnit 5 can be included as: