matsim-libs icon indicating copy to clipboard operation
matsim-libs copied to clipboard

migrate to JUnit5

Open michalmac opened this issue 4 years ago • 2 comments

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...

michalmac avatar Jan 28 '21 13:01 michalmac

https://stackoverflow.com/questions/46242083/how-to-automatically-migrate-from-junit-4-to-junit-5

michalmac avatar Mar 03 '21 21:03 michalmac

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.

mrieser avatar Mar 03 '21 21:03 mrieser