How can I apply a single junit-platform.properties to all modules in my project.
My project has 3 separate modules, each with its own test + resources.
Currently I'm duplicating and placing them in each resources directory. How can I reduce it to just 1 centralized junit-platform.properties and where should I place it?
The junit5 guide 4.5. Configuration Parameters describes
The JUnit Platform configuration file: a file named junit-platform.properties in the root of the class path that follows the syntax rules for a Java Properties file.
Therefore you could create a common project with your junit-platform.properties
and add this project into the classpath for each of your projects.
for Eclipse workspace
Create baseproject
with junit-platform.properties
file.
junit-platform.properties with custom conmfiguration e.g. junit.jupiter.displayname.generator.default
junit.jupiter.displayname.generator.default = org.junit.jupiter.api.DisplayNameGenerator$ReplaceUnderscores
Other project project2
without any own junit-platform.properties
add baseproject
to java build path of project2
Launching Junit test added baseproject
into the classpath
Result of Junit test shows test display name with replaced underscores
for IntelliJ workspace with gradle
Using IntelliJ workspace , e.g. junitconfig
.
Add module baseproject
for junit-platform.properties
(as resource)
Add module project2
for your Java files and Junit test files.
Add module baseproject
as dependency for module project2
in build.gradle
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation project(':baseproject')
}
rebuild module project2
and run junit test