matsim-libs
matsim-libs copied to clipboard
migrate to JUnit5
There are a few improvements to jUnit 5 (e.g. nested unit test classes) that help writing cleaner tests. There are a few little hurdles when switching from 4 to 5 (e.g. parametrisation is per test method, instead of per test class), but nothing big.
This could be a task to pick up during a code sprint...
https://stackoverflow.com/questions/46242083/how-to-automatically-migrate-from-junit-4-to-junit-5
I think one can switch step-by-step (or test-by-test) by using the vintage dependency. I currently have the following unit-dependencies in one of my projects:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
and this way I can use the new JUnit 5 features, but the older JUnit 4 tests work as well. Not sure about the JUnit 3 tests we might still have in MATSim.