szpak / gradle-pitest-plugin

Gradle plugin for PIT Mutation Testing
http://gradle-pitest-plugin.solidsoft.info/
211 stars 57 forks source link

Task 'pitest' not found in root project (Running pitest with Gradle 8.7) #361

Closed Bhumika2005 closed 1 month ago

Bhumika2005 commented 1 month ago

In demo project, I have added pitest plugin in libs.versions.toml as below:

[versions]
....
kotlin = "1.9.0"
pitest = "1.15.0"

[libraries]
....

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
pitest = {id = "info.solidsoft.pitest", version.ref = "pitest"}

Then added plugin in app build.gradle => build.gradle.kts(:app)

plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.pitest)
}

build successful but ./gradlew pitest didn't work and getting error as below ::

FAILURE: Build failed with an exception.

* What went wrong:
Task 'pitest' not found in root project 'TestPitest' and its subprojects. Some candidates are: 'test'.

Then I found this issue link and tried the same way

Added dependency in app build.gradle.kts along with above change

dependencies {
    ....
 testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
pitest("org.pitest:pitest-testng-plugin:1.0.0")
}

still same error message - "Task 'pitest' not found in root project 'TestPitest' and its subprojects. Some candidates are: 'test' "

Also added plugin / buildscript dependencies in root project build.gradle but nothing works.

Getting same error message everytime.

szpak commented 1 month ago

Please reformat you question to make the code readable: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

Bhumika2005 commented 1 month ago

https://github.com/szpak/gradle-pitest-plugin/issues/361#issuecomment-2118093663

Updated

szpak commented 1 month ago

Thanks.

Now, I've realized it's an Android app. There's a dedicated plugin variant made especially for the Android projects: https://github.com/koral--/gradle-pitest-plugin/ . You could give it a try.

Bhumika2005 commented 1 month ago

Thank you!