Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

374
Views
Test classes in Groovy don't see test classes in Kotlin

I have gradle project with Kotlin plugin.

In my project I uses groovy and Spock for tests. One of utility classes used in tests in written in Kotlin and I put it to src/test/kotlin

I'm trying to use this class from groovy tests (Spock specification), I see that "compileTestKotlin" task runs first and compiles my utility class, but still "compileTestGroovy" fails, because it does not see it.

How can I fix this situation? How to add build/classes/kotlin/test/ to the compilation classpath of groovy tests?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The issue is that by default compileTestGroovy doesn't include build/classes/kotlin/test folder, so your Kotlin util class cannot be seen from Groovy tests.

In order to fix it you can manually add Kotlin test sources to compileTestGroovy's classpath. Add the following to your build.gradle:

compileTestGroovy.classpath += files(compileTestKotlin.destinationDir)

If your build file is build.gradle.kts, add the following

// make groovy test code depend on kotlin test code
tasks.named<GroovyCompile>("compileTestGroovy") {
    classpath += files(tasks.compileTestKotlin)
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!