I have a JavaFX-based project written in Kotlin that has both unit tests and integration tests. I recently added an integration test which touches a class that uses ObservableMap
. When I try to run integration tests with Gradle, it gives me the error ‘Cannot access class ‘javafx.collections.ObservableMap’. Check your module classpath for missing or conflicting dependencies’.
Here is my build.gradle.kts with irrelevant lines removed:
version = "0.1.0"
plugins {
kotlin("jvm") version "1.9.0"
id("org.openjfx.javafxplugin") version "0.0.14"
`jvm-test-suite`
application
}
repositories { /* ... */ }
dependencies {
// ...
// GUI and controls
implementation("org.openjfx:javafx-plugin:0.0.14")
implementation("org.openjfx:javafx-base:22")
implementation("org.openjfx:javafx-controls:22")
implementation("org.controlsfx:controlsfx:11.2.1")
// JUnit 5 with Kotlin
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.2")
// ...
}
testing {
suites {
@Suppress("UnstableApiUsage")
val integrationTest by registering(JvmTestSuite::class) {
dependencies {
implementation(project())
// unrelated dependency entries removed for clarity
}
}
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
javafx {
modules("javafx.controls", "javafx.web")
}
application {
mainClass.set("connect.AppKt")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
// ...
Adding the implementation
lines for the relevant libraries to the integration test dependencies doesn’t solve the problem.
I’ve run a build scan and nothing jumps out as the problem, nor does running Gradle with the –info switch.
Integration tests which depend on other libraries in my project don’t have this problem. Suggestions?