Caleb Cushing
08/07/2024, 6:13 PMtesting {
suites {
withType<JvmTestSuite>().configureEach {
useJUnitJupiter()
tasks.withType<Test>().configureEach {
useJUnitPlatform()Sebastian Schuberth
08/07/2024, 6:41 PMNote that all suites other than the built-insuite will by convention work as iftestwas called.useJUnitJupiter()
Vampire
08/07/2024, 7:09 PMCaleb Cushing
08/07/2024, 7:34 PMCaleb Cushing
08/07/2024, 7:35 PMCaleb Cushing
08/07/2024, 7:35 PMCaleb Cushing
08/07/2024, 7:35 PMVampire
08/07/2024, 7:38 PMuseJUnitPlatform() just means use the JUnit 5 platform to launch tests
useJupiter() means use the JUnit 5 platform to launch tests, add the Jupiter engine so that Jupiter tests are found, and add the Jupiter API so that you can code the tests using Jupiter
The version used are hard-coded defaults, or you can give them as argument to those methods.
It should work with the Spring BOM like any other dependency.Caleb Cushing
08/07/2024, 7:40 PMjunit-api = { module = "org.junit.jupiter:junit-jupiter-api" }
junit-bom = "org.junit:junit-bom:5.+"
junit-parameters = { module = "org.junit.jupiter:junit-jupiter-params" }
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
junit-launcher = { module = "org.junit.platform:junit-platform-launcher" }
am I wrong? how does it know what version to use? spring boot adds a version for this, obviously I'm resolving my own (I forget why, but I am increasingly untrusting of spring boot's dependency decisions)Vampire
08/07/2024, 7:41 PMjunit-parameters, but I use Spock for tests everywhere, that is what makes testing fun again. 🙂Vampire
08/07/2024, 7:42 PMCaleb Cushing
08/07/2024, 7:42 PMCaleb Cushing
08/07/2024, 7:42 PMVampire
08/07/2024, 7:42 PMCaleb Cushing
08/07/2024, 7:42 PMCaleb Cushing
08/07/2024, 7:43 PMVampire
08/07/2024, 7:43 PMVampire
08/07/2024, 7:44 PMso if I added -params, how would I know what version I was going to getProbably depends on whether JUnit properly published version alignment metadata
Caleb Cushing
08/07/2024, 7:44 PMVampire
08/07/2024, 7:44 PMCaleb Cushing
08/07/2024, 7:44 PMVampire
08/07/2024, 7:44 PMVampire
08/07/2024, 7:44 PMCaleb Cushing
08/07/2024, 7:44 PMVampire
08/07/2024, 7:45 PMCaleb Cushing
08/07/2024, 7:45 PMVampire
08/07/2024, 7:45 PMVampire
08/07/2024, 7:46 PMVampire
08/07/2024, 7:47 PMVampire
08/07/2024, 7:47 PMVampire
08/07/2024, 7:47 PMCaleb Cushing
08/07/2024, 7:47 PMVampire
08/07/2024, 7:47 PMVampire
08/07/2024, 7:48 PMuseJupiter() is practically that.Caleb Cushing
08/07/2024, 7:49 PMCaleb Cushing
08/07/2024, 7:49 PMVampire
08/07/2024, 7:49 PMCaleb Cushing
08/07/2024, 7:50 PMCaleb Cushing
08/07/2024, 7:51 PMCaleb Cushing
08/07/2024, 7:51 PMCaleb Cushing
08/07/2024, 7:52 PMCaleb Cushing
08/07/2024, 7:53 PMCaleb Cushing
08/07/2024, 7:53 PMVampire
08/07/2024, 7:59 PMCaleb Cushing
08/07/2024, 7:59 PMCaleb Cushing
08/07/2024, 8:00 PMCaleb Cushing
08/07/2024, 8:13 PMCaleb Cushing
08/07/2024, 8:14 PMVampire
08/07/2024, 9:14 PMtbh, you don't seem to be telling me the right way to add -parameters and how that'd interact safely with the builtins, so that alone is a red flagIt just means I'm not using Jupiter
Caleb Cushing
08/07/2024, 9:16 PMVampire
08/07/2024, 9:19 PMtesting {
suites {
val test by existing(JvmTestSuite::class) {
useJUnitJupiter("5.+")
dependencies {
implementation("org.junit.jupiter:junit-jupiter-params")
}
}
}
}Vampire
08/07/2024, 9:19 PMseems like you wouldn't want this behavior because it would add a jar to your implementation that you don't want (the api)Why would you not want the api? Without you cannot write any tests
Vampire
08/07/2024, 9:20 PMCaleb Cushing
08/07/2024, 9:20 PMCaleb Cushing
08/07/2024, 9:20 PMVampire
08/07/2024, 9:20 PMtestRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.junit.jupiter:junit-jupiter-params -> 5.11.0-RC1
| +--- org.junit:junit-bom:5.11.0-RC1
| | +--- org.junit.jupiter:junit-jupiter:5.11.0-RC1 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.11.0-RC1 (c)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.11.0-RC1 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.11.0-RC1 (c)
| | +--- org.junit.platform:junit-platform-launcher:1.11.0-RC1 (c)
| | +--- org.junit.platform:junit-platform-commons:1.11.0-RC1 (c)
| | \--- org.junit.platform:junit-platform-engine:1.11.0-RC1 (c)
| \--- org.junit.jupiter:junit-jupiter-api:5.11.0-RC1
| +--- org.junit:junit-bom:5.11.0-RC1 (*)
| +--- org.opentest4j:opentest4j:1.3.0
| \--- org.junit.platform:junit-platform-commons:1.11.0-RC1
| \--- org.junit:junit-bom:5.11.0-RC1 (*)
+--- org.junit.jupiter:junit-jupiter:5.+ -> 5.11.0-RC1
| +--- org.junit:junit-bom:5.11.0-RC1 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.11.0-RC1 (*)
| +--- org.junit.jupiter:junit-jupiter-params:5.11.0-RC1 (*)
| \--- org.junit.jupiter:junit-jupiter-engine:5.11.0-RC1
| +--- org.junit:junit-bom:5.11.0-RC1 (*)
| +--- org.junit.platform:junit-platform-engine:1.11.0-RC1
| | +--- org.junit:junit-bom:5.11.0-RC1 (*)
| | +--- org.opentest4j:opentest4j:1.3.0
| | \--- org.junit.platform:junit-platform-commons:1.11.0-RC1 (*)
| \--- org.junit.jupiter:junit-jupiter-api:5.11.0-RC1 (*)
\--- org.junit.platform:junit-platform-launcher -> 1.11.0-RC1
+--- org.junit:junit-bom:5.11.0-RC1 (*)
\--- org.junit.platform:junit-platform-engine:1.11.0-RC1 (*)Caleb Cushing
08/07/2024, 9:21 PMCaleb Cushing
08/07/2024, 9:21 PMVampire
08/07/2024, 9:22 PMVampire
08/07/2024, 9:22 PMCaleb Cushing
08/07/2024, 9:23 PMVampire
08/07/2024, 9:23 PMuseJUnitJupiter("5.9.0")
dependencies {
implementation("org.junit.jupiter:junit-jupiter-params:5.10.0")
}
Uses 5.10.0 for everything.Vampire
08/07/2024, 9:24 PMVampire
08/07/2024, 9:24 PMCaleb Cushing
08/07/2024, 9:25 PMCaleb Cushing
08/07/2024, 9:25 PMVampire
08/07/2024, 9:26 PMCaleb Cushing
08/07/2024, 9:26 PMCaleb Cushing
08/07/2024, 9:27 PMresolutionStrategy {
componentSelection {
all {
val nonRelease = Regex("^[\\d.]+-(RC|M|ea|beta|alpha).*$")
val module = Regex("^spotbugs.*")
val group = Regex("^com.xenoterracide$")
if (!candidate.group.matches(group) && !name.matches(module) && !candidate.module.matches(module)) {
if (candidate.version.matches(nonRelease)) reject("no pre-release")
if (candidate.version.endsWith("-SNAPSHOT")) reject("no snapshots")
} else if (candidate.version.matches(nonRelease)) {
<http://logger.info|logger.info>("allowing: {}", candidate)
}Caleb Cushing
08/07/2024, 9:27 PMRCVampire
08/07/2024, 9:29 PM.* then it's clear. 😄
Like shown it works fine.Caleb Cushing
08/07/2024, 9:32 PM...(M|...Caleb Cushing
08/07/2024, 9:32 PMCaleb Cushing
08/07/2024, 9:32 PMjunit-jupiter doesn't actually exist in most of my modulesCaleb Cushing
08/07/2024, 9:33 PMCaleb Cushing
08/07/2024, 9:33 PMCaleb Cushing
08/07/2024, 9:33 PMVampire
08/07/2024, 9:34 PMVampire
08/07/2024, 9:34 PMCaleb Cushing
08/07/2024, 9:36 PM./gradlew :jpa:dependencyInsight --configuration testRuntimeClasspath --dependency junit-jupiter | grep "junit-jupiter:"
without the grep
Reusing configuration cache.
> Task :jpa:dependencyInsight
org.junit.jupiter:junit-jupiter-api:5.10.3
Variant runtimeElements:
| Attribute Name | Provided | Requested |
|------------------------------------|--------------|--------------|
| org.gradle.status | release | |
| org.jetbrains.kotlin.platform.type | jvm | |
| org.gradle.category | library | library |
| org.gradle.dependency.bundling | external | external |
| org.gradle.jvm.environment | standard-jvm | standard-jvm |
| org.gradle.jvm.version | 8 | 21 |
| org.gradle.libraryelements | jar | jar |
| org.gradle.usage | java-runtime | java-runtime |
Selection reasons:
- By constraint: dependency was locked to version '5.10.3'
- By ancestor
org.junit.jupiter:junit-jupiter-api:{strictly 5.10.3} -> 5.10.3
\--- project :jpa
\--- project :jpa (*)
org.junit.jupiter:junit-jupiter-api:5.10.3
+--- org.junit:junit-bom:5.10.3
| +--- project :jpa (requested org.junit:junit-bom:5.+)
| | \--- project :jpa (*)
| +--- org.junit.jupiter:junit-jupiter-params:5.10.3
| | +--- project :jpa (requested org.junit.jupiter:junit-jupiter-params) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2
| | | +--- project :jpa (requested org.springframework.boot:spring-boot-dependencies:3.+) (*)
| | | +--- project :model (requested org.springframework.boot:spring-boot-dependencies:3.+)
| | | | \--- project :jpa (*)
| | | \--- project :test-app (requested org.springframework.boot:spring-boot-dependencies:3.+)
| | | \--- project :jpa (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.jupiter:junit-jupiter-engine:5.10.3
| | +--- project :jpa (requested org.junit.jupiter:junit-jupiter-engine) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.3 (*)
| +--- org.junit.platform:junit-platform-launcher:1.10.3
| | +--- project :jpa (requested org.junit.platform:junit-platform-launcher) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.platform:junit-platform-engine:1.10.3
| | +--- project :jpa (requested org.junit.platform:junit-platform-engine:{strictly 1.10.3}) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
| | +--- org.junit.platform:junit-platform-launcher:1.10.3 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| \--- org.junit.platform:junit-platform-commons:1.10.3
| +--- project :jpa (requested org.junit.platform:junit-platform-commons:{strictly 1.10.3}) (*)
| +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.3 (*)
| +--- org.junit.platform:junit-platform-engine:1.10.3 (*)
| \--- org.junit:junit-bom:5.10.3 (*)
+--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
+--- org.junit.jupiter:junit-jupiter-params:5.10.3 (*)
\--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
org.junit.jupiter:junit-jupiter-api -> 5.10.3
\--- project :jpa
\--- project :jpa (*)
org.junit.jupiter:junit-jupiter-engine:5.10.3
Variant runtimeElements:
| Attribute Name | Provided | Requested |
|------------------------------------|--------------|--------------|
| org.gradle.status | release | |
| org.jetbrains.kotlin.platform.type | jvm | |
| org.gradle.category | library | library |
| org.gradle.dependency.bundling | external | external |
| org.gradle.jvm.environment | standard-jvm | standard-jvm |
| org.gradle.jvm.version | 8 | 21 |
| org.gradle.libraryelements | jar | jar |
| org.gradle.usage | java-runtime | java-runtime |
Selection reasons:
- By constraint: dependency was locked to version '5.10.3'
- By ancestor
org.junit.jupiter:junit-jupiter-engine:{strictly 5.10.3} -> 5.10.3
\--- project :jpa
\--- project :jpa (*)
org.junit.jupiter:junit-jupiter-engine:5.10.3
+--- org.junit:junit-bom:5.10.3
| +--- project :jpa (requested org.junit:junit-bom:5.+)
| | \--- project :jpa (*)
| +--- org.junit.jupiter:junit-jupiter-params:5.10.3
| | +--- project :jpa (requested org.junit.jupiter:junit-jupiter-params) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2
| | | +--- project :jpa (requested org.springframework.boot:spring-boot-dependencies:3.+) (*)
| | | +--- project :model (requested org.springframework.boot:spring-boot-dependencies:3.+)
| | | | \--- project :jpa (*)
| | | \--- project :test-app (requested org.springframework.boot:spring-boot-dependencies:3.+)
| | | \--- project :jpa (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.3
| | +--- project :jpa (requested org.junit.jupiter:junit-jupiter-api) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | +--- org.junit.jupiter:junit-jupiter-params:5.10.3 (*)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.platform:junit-platform-launcher:1.10.3
| | +--- project :jpa (requested org.junit.platform:junit-platform-launcher) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.platform:junit-platform-engine:1.10.3
| | +--- project :jpa (requested org.junit.platform:junit-platform-engine:{strictly 1.10.3}) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
| | +--- org.junit.platform:junit-platform-launcher:1.10.3 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| \--- org.junit.platform:junit-platform-commons:1.10.3
| +--- project :jpa (requested org.junit.platform:junit-platform-commons:{strictly 1.10.3}) (*)
| +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.3 (*)
| +--- org.junit.platform:junit-platform-engine:1.10.3 (*)
| \--- org.junit:junit-bom:5.10.3 (*)
\--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
org.junit.jupiter:junit-jupiter-engine -> 5.10.3
\--- project :jpa
\--- project :jpa (*)
org.junit.jupiter:junit-jupiter-params:5.10.3
Variant runtimeElements:
| Attribute Name | Provided | Requested |
|------------------------------------|--------------|--------------|
| org.gradle.status | release | |
| org.jetbrains.kotlin.platform.type | jvm | |
| org.gradle.category | library | library |
| org.gradle.dependency.bundling | external | external |
| org.gradle.jvm.environment | standard-jvm | standard-jvm |
| org.gradle.jvm.version | 8 | 21 |
| org.gradle.libraryelements | jar | jar |
| org.gradle.usage | java-runtime | java-runtime |
Selection reasons:
- By constraint: dependency was locked to version '5.10.3'
- By ancestor
org.junit.jupiter:junit-jupiter-params:{strictly 5.10.3} -> 5.10.3
\--- project :jpa
\--- project :jpa (*)
org.junit.jupiter:junit-jupiter-params:5.10.3
+--- org.junit:junit-bom:5.10.3
| +--- project :jpa (requested org.junit:junit-bom:5.+)
| | \--- project :jpa (*)
| +--- org.junit.jupiter:junit-jupiter-params:5.10.3 (*)
| +--- org.junit.jupiter:junit-jupiter-engine:5.10.3
| | +--- project :jpa (requested org.junit.jupiter:junit-jupiter-engine) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2
| | | +--- project :jpa (requested org.springframework.boot:spring-boot-dependencies:3.+) (*)
| | | +--- project :model (requested org.springframework.boot:spring-boot-dependencies:3.+)
| | | | \--- project :jpa (*)
| | | \--- project :test-app (requested org.springframework.boot:spring-boot-dependencies:3.+)
| | | \--- project :jpa (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.3
| | +--- project :jpa (requested org.junit.jupiter:junit-jupiter-api) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | +--- org.junit.jupiter:junit-jupiter-params:5.10.3 (*)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.platform:junit-platform-launcher:1.10.3
| | +--- project :jpa (requested org.junit.platform:junit-platform-launcher) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| +--- org.junit.platform:junit-platform-engine:1.10.3
| | +--- project :jpa (requested org.junit.platform:junit-platform-engine:{strictly 1.10.3}) (*)
| | +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.3 (*)
| | +--- org.junit.platform:junit-platform-launcher:1.10.3 (*)
| | \--- org.junit:junit-bom:5.10.3 (*)
| \--- org.junit.platform:junit-platform-commons:1.10.3
| +--- project :jpa (requested org.junit.platform:junit-platform-commons:{strictly 1.10.3}) (*)
| +--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.3 (*)
| +--- org.junit.platform:junit-platform-engine:1.10.3 (*)
| \--- org.junit:junit-bom:5.10.3 (*)
\--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
org.junit.jupiter:junit-jupiter-params -> 5.10.3
\--- project :jpa
\--- project :jpa (*)
(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 772ms
1 actionable task: 1 executed
Configuration cache entry reused.Caleb Cushing
08/07/2024, 9:38 PMVampire
08/07/2024, 9:46 PMjunit-jupiter artifact is just a meta package anyway.Vampire
08/07/2024, 9:46 PMVampire
08/07/2024, 9:47 PMVampire
08/07/2024, 9:47 PM-params, so if you have junit-jupiter -params is already includedCaleb Cushing
08/07/2024, 9:47 PMVampire
08/07/2024, 9:47 PMuseJunitJupiter