This message was deleted.
# community-support
s
This message was deleted.
t
You have to declare the
functionalTest
compilation as a associated with the main compilation:
Copy code
kotlin.target.compilations.named("functionalTest") {
    associateWith(kotlin.target.compilations["main"])
}
The Kotlin plugin does that automatically for the
test
source set, but you have to do it manually for any other source set (e.g. testing suites)
thank you 1
j
does
compilations
exist outside of KMP?
ah okay, it exists on
KotlinJvmProjectExtension
too, but not on
KotlinProjectExtension
testFixtures
by default has the same problem, I guess it is an intended behavior, right?
🤷 1
I tried to do the same with
testFixtures
but no luck 🤷
Copy code
kotlin.target.compilations.named("functionalTest") {
    associateWith(kotlin.target.compilations["testFixtures"])
}
Do I need to do something special for getting plugin under test working?
Copy code
Test runtime classpath does not contain plugin metadata file 'plugin-under-test-metadata.properties'
org.gradle.testkit.runner.InvalidPluginMetadataException: Test runtime classpath does not contain plugin metadata file 'plugin-under-test-metadata.properties'
Copy code
val testPluginClasspath: Configuration =
    configurations.create("testPluginClasspath")

dependencies {
    for (dependency in pluginUnderTestDependencies) {
        testPluginClasspath(dependency)
    }
}

tasks.withType<PluginUnderTestMetadata>().configureEach { metadata ->
    metadata.pluginClasspath.from(testPluginClasspath)
}
It was working on
test
source set, but fails on
functionalTest
one
e
Copy code
kotlin.target.compilations {
    val main by getting
    val testFixtures by getting {
        associateWith(main)
    }
    named("functionalTest") {
        associateWith(main)
        associateWith(testFixtures)
    }
}
compiles fine for me with access to
internal
across source sets, the only problem is the IDE not recognizing it
you can use
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
to bypass
internal
protection as well. the IDE won't help with auto-complete but it'll stop showing red errors
t
Wrt plugin-under-test-metadata:
Copy code
gradlePlugin {
    testSourceSets(project.sourceSets["functionalTest"])
}
thank you 1
j
Looks like it is getting cached and it passes even when it should fail. I run from the IDE and it fails, but when running it via terminal it passes and the tests are not running. Should I config something more?
Indeed it only fails from IDE, from terminal even using
--rerun-tasks
it passes 🤔
Looks like it was fixed alone, some weird cache I guess
t
You don't delegate to Gradle when running from the IDE? (assuming you're using some flavor of JetBrains' IDE, no idea how things work in other IDEs)
j
Yeah, that was the weird part, IDE uses Gradle and it was failing correctly but via terminal it was passing. But looks like it is fixed