Introduction
Hey everyone,
This merge request aims to migrate all Orekit tests from JUnit4 to JUnit5.
I apologize in advance for the mess in my commits, i started from the wrong branch so i had to delete a few things (still learning git).
Process summary
In order to migrate all tests, i initially used a macro available in IntelliJ which did part of the work. Lots of CTRL + R
were also used to replace old assertions with their new equivalent.
The Pom now uses the following dependencies:
- junit-jupiter-api (v5.9.0) (essentially the core of JUnit5)
- junit-jupiter-engine (v5.9.0) (needed because of the maven surefire plugin 2.22.0+)
- hamcrest-library (v2.2) (was initially integrated in JUnit4 but is now independent)
Exception tests
From there i mainly had to manually replace tests that expected an exception to be thrown, which used :
@Test(expected = Exception.class)
public void shouldRaiseAnException() throws Exception {
// ...
}
By the JUnit5 equivalent :
public void shouldRaiseAnException() throws Exception {
Assertions.assertThrows(Exception.class, () -> {
//...
});
}
Temporary folder & Rule
The other tests where i had to manually intervene were the tests that used the TemporaryFolder
class. In this case, the JUnit5 equivalent is the @TempDir
annotation. For example, if we had :
class SomeTest {
@Rule
TemporaryFolder tmp = new TemporaryFolder();
// tests ...
}
Then it was replaced with :
class SomeTest {
@TempDir
Path(or File) directory;
// tests ...
}
Others
I took the opportunity to fix some documentation that didn't use some parameters anymore or with different names.
Sources
For those interested in the detailed process, here is what i used to do the migration: