Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure JVM args for the new Gradle TestSuit?

I am trying the new TestSuit from Gradle. I have this in my project:

testing {
    suites {
        val integrationTest by registering(JvmTestSuite::class) { 
            useJUnitJupiter()
            jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
            jvmArgs("--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED")
        }
}

But when I run ./gradlew integrationTest, I get:

/buildSrc/src/main/kotlin/quarkus-testing.quarkus-conventions.gradle.kts: (35, 13): Unresolved reference: jvmArgs

How to configure jvmArgs now?

like image 422
AmsterdamLuis Avatar asked Oct 20 '25 02:10

AmsterdamLuis


1 Answers

I recently solved this by working down the hierarchy, from the JvmTestSuite object to the Test object which is the object that contains the jvmArgs reference.

testing {
    suites {
        val integrationTest by registering(JvmTestSuite::class) {
            useJUnitJupiter()

            // here:  really calling JvmTestSuite#getTargets() then,
            //        DomainObjectCollection#all(Action)
            targets.all {
                // here:  really calling JvmTestSuiteTarget#getTestTask() then,
                //        TaskProvider#configure(Action)
                testTask.configure {
                    // now we're operating on a Test instance
                    jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
                    jvmArgs("--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED")
                }
            }
        }
    }
}
like image 91
CrashNeb Avatar answered Oct 22 '25 04:10

CrashNeb