0

Is Kotest5 compatible with pitest?

I'm using Kotest5 for my tests with a micronaut application. I am using the gradle-pitest-plugin as well as the Kotest pitest extension like the docs say. However I keep getting an error like enter image description here

The testing dependencies I have declared in my project are

"io.micronaut.test:micronaut-test-kotest5:3.6.2"
"io.kotest:kotest-runner-junit5-jvm:5.3.0"
"io.kotest.extensions:kotest-extensions-pitest:1.1.0"

I am using the following pitest gradle plugin version

'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0'

and my pitest configuration block looks as follows:

pitest {
    targetClasses = ["my.group.*"]  //by default "${project.group}.
    pitestVersion = '1.9.0' //not needed when a default PIT version should be used
    threads = 4
    outputFormats = ['XML', 'HTML']
    timestampedReports = false
}

All the working examples I can find are instances where Kotest 4 is being used, but I can't find any changelogs where that is stated. I haven't tried going back to Kotest 4, and I'm not sure pitest offers enough value for me to do that, but maybe it simply isn't compatible!

Rob Schwartz
  • 192
  • 1
  • 12

2 Answers2

1

Looking at the kotest pitest plugin repo, it is being built against pitest 1.8.0. There was a major interface change to the test plugin interface in pitest 1.9.0

https://github.com/hcoles/pitest/releases/1.9.0

Until the plugin is updated it can only be used with pitest 1.8.1.

henry
  • 5,923
  • 29
  • 46
  • Interesting- good find! I'm still having the same issues- here are the versions I'm using. `info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0` `io.kotest.extensions:kotest-extensions-pitest:1.1.0` And the configured piTest version with the gradle plugin is now `pitestVersion = '1.8.1'` However I still get the same error. I am now curious if there is a Junit version mismatch somewhere in my project as I believe that's what's being used as the runner. – Rob Schwartz Jan 26 '23 at 15:22
  • If you enable pitest's verbose logging there may be some clues as to what the issue is. – henry Jan 26 '23 at 20:19
  • Unfortunately it doesn't give anything else out since the "configuration" of pitest is working I think. However I didn't realize my screenshot left out a key piece that I didn't mean to leave out. That line is `2:43:12 PM PIT >> FINE : MINION : java.lang.NoSuchMethodError: 'io.kotest.core.descriptors.TestPath io.kotest.core.descriptors.Descriptor$DefaultImpls.path$default(io.kotest.core.descriptors.Descriptor, boolean, int, java.lang.Object)'`. I have found that the Kotest Spring extension had issues with this method but I can't find any fix/solution for the Kotest extension for pitest. – Rob Schwartz Jan 26 '23 at 20:52
  • Ha- ok so I followed what the spring extension issue was for Kotest, and I was reading the issue came into play when kotest 5.4.0 was introduced. So I forced all versions of Kotest to use 5.3.2 and now pitest is working! I'll dig a little deeper to find why that is the case to hopefully get that fixed. – Rob Schwartz Jan 26 '23 at 21:12
  • There is a new build of the kotest pitest extension now that works with 1.9.0 – sksamuel Feb 05 '23 at 14:29
0

Thanks to Henry, I found there was a regression introduced with Kotest 5.4.0. So I have forced all versions of Kotest in my project to 5.3.2 by doing the following:

allprojects {
    configurations.all {
        resolutionStrategy.eachDependency {
            if (it.requested.group == 'io.kotest') {
                it.useVersion '5.3.2'
            }
        }
    }
}

And then Pitest worked perfectly! So this is not an issue with Pitest or the Pitest Gradle plugin as far as I can tell.

I've opened an issue with kotest and the pitest extension here as well for others to follow.

Rob Schwartz
  • 192
  • 1
  • 12