Has anyone figured out how to add a custom jvm sou...
# multiplatform
b
Has anyone figured out how to add a custom jvm sourceSet and testSuite in an mpp project? Something like
jvmIntegrationTest
b
Thanks, that helped
Copy code
jvm {
    compilations {
      val main by getting
      val instrumentedTest by creating {
        defaultSourceSet.dependsOn(main.defaultSourceSet)
      }
      val testTask = tasks.register<Test>("jvmInstrumentedTest") {
        group = "verification"
        classpath = instrumentedTest.runtimeDependencyFiles
      }
      tasks.named("allTests") { dependsOn(testTask) }
    }
  }
Wait, not quite - my tests are still not getting picked up
Copy code
compilations {
      val main by getting
      val instrumentedTest by creating {
        defaultSourceSet.dependsOn(main.defaultSourceSet)
      }
      val testTask = tasks.register<Test>("jvmInstrumentedTest") {
        dependsOn(instrumentedTest.compileTaskProvider)
        group = "verification"
        classpath = instrumentedTest.runtimeDependencyFiles
        testClassesDirs = instrumentedTest.defaultSourceSet.kotlin.sourceDirectories
      }
      tasks.named("allTests") { dependsOn(testTask) }
    }
With this I'm getting test class picked up, but the test run is failing with
ClassNotFoundException
for the test class
Copy code
compilations {
      val main by getting
      val instrumentedTest by creating {
        defaultSourceSet.dependsOn(main.defaultSourceSet)
      }
      val testTask = tasks.register<Test>("jvmInstrumentedTest") {
        dependsOn(instrumentedTest.compileTaskProvider)
        group = "verification"
        classpath =
          instrumentedTest.compileDependencyFiles + instrumentedTest.runtimeDependencyFiles
        testClassesDirs = instrumentedTest.output.classesDirs
        shouldRunAfter("jvmTest")
        testLogging { events("passed") }
      }
      tasks.named("allTests") { dependsOn(testTask) }
    }