Pitest in a Kotlin project with Gradle

162 views
Skip to first unread message

Antonio Román Crespo

unread,
Oct 6, 2021, 10:01:52 AM10/6/21
to PIT Users
Hi everyone,
I am trying to execute Pitest in my Kotlin project with Gradle and it is not working at all. My build.gradle.kts looks like this:

import info.solidsoft.gradle.pitest.PitestTask

buildscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath("info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.0")
    }
}

plugins {
    java
    kotlin("jvm") version "1.5.21"
    kotlin("kapt") version "1.5.21"
}

allprojects {
    group = "com.loyalty.core"
}

subprojects {
    apply(plugin = "java")
    apply(plugin = "kotlin")
    apply(plugin = "org.jetbrains.kotlin.kapt")
    apply(plugin = "info.solidsoft.pitest")

    tasks {
        withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
            kotlinOptions.jvmTarget = "15"
        }

        withType<PitestTask> {
            testPlugin.set("junit5")
            threads.set(1)
            outputFormats.set(setOf("XML", "HTML"))
            mutators.set(setOf("STRONGER", "DEFAULTS"))
            avoidCallsTo.set(setOf("kotlin.jvm.internal", "kotlinx.coroutines"))
        }
    }

Can anyone tell me what I am doing wrong?

King regards!!
Antonio

Marcin Zajączkowski

unread,
Oct 6, 2021, 3:38:50 PM10/6/21
to 'Joni' via PIT Users
On 2021-10-06 16:01, Antonio Román Crespo wrote:
> Hi everyone,
> I am trying to execute Pitest in my Kotlin project with Gradle and it is
> not working at all. My build.gradle.kts looks like this:

Hi Antonio,

I don't use Kotlin with PIT, but you may take a look at the sample
Kotlin project in the gradle-pitest-plugn functional test. It seems to
pass, so probably some mutations are killed there :).

https://github.com/szpak/gradle-pitest-plugin/tree/master/src/funcTest/resources/testProjects/junit5kotlin

Maybe it will help you find a problem.

Marcin
Reply all
Reply to author
Forward
0 new messages