Trying to setup integration tests that depend on a...
# gradle
a
Trying to setup integration tests that depend on a common test utility project. Having trouble resolving with Kotlin MPP. Right now just trying to get JVM to work. The "test-utils" project builds fine, gradle seems happy overall but the classes from the "test-utils" project are not resolved and can't be imported in "project A" tests.
Copy code
// project A

val integrationTest by creating {
    kotlin.srcDir("it")
    dependsOn(getByName("jvmTest"))
    dependencies {
        implementation(project(":test-utils", "jvmMainImplementation"))
        implementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
        implementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
    }
}
I've tried various incantations of depending on the "test-utils" project including custom configurations. I was working on setting up a test Jar output but also having trouble with Gradle Kotlin DSL and MPP.
Copy code
// project "test-utils"
kotlin {
    sourceSets {
        jvmMain {
            dependencies {
                api("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
                api("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
                ...
            }
        }
    }
}
I can't tell which I'm fighting, Gradle Kotlin DSL, Kotlin MPP, or both. The generic problem: How to setup a custom (test) source set and depend on another project that provides common test utils using Kotlin MPP? I've seen examples of this without Kotlin MPP but that seems to be adding an extra layer that I haven't connected. Any ideas or examples to look at?
👍 1
j
i've started a bounty for something similar, don't know if you've solved your issue yet? https://stackoverflow.com/questions/62665410/linking-dependencies-with-gradle-6-5-in-a-kotlin-multiplatform-project/62667422#62667422
a
Sorry have not spent anymore time on this yet
j
issue is solved in that SO question, so if you're looking for sample code, just check out the linked Github Repo
a
Awesome thanks! I'll check it out