I have this approximate project structure:
project/
├── module-with-java-code/
│ ├── main
│ ├── test
│ └── build.gradle
├── module-with-cucumber-features/
│ ├── features [test]/
│ │ ├── feature-test-folder-1/
│ │ │ ├── test-1.feature
│ │ │ └── -...
│ │ └── ...
│ ├── test/
│ │ ├── glue/
│ │ │ └── glues...
│ │ ├── TestNgCucumberTest for feature-test-folder-1
│ │ └── ...
│ └── build.gradle
├── way more more modules...
└── build.gradle
I want to execute Pitest on code in module-with-java-code but i want to run it with tests inside its own module and the feature tests from module-with-cucumber-features.
The versions i am using:
- gradle: 8.11.1
- pitest-gradle-plugin: ‘info.solidsoft.pitest’ version ‘1.15.0’
- pitest-testng-plugin: ‘org.pitest:pitest-testng-plugin:1.0.0’
- pitest-junit5-plugin: ‘org.pitest:pitest-junit5-plugin:1.2.1’
- cucumber
- ‘io.cucumber:cucumber-jvm-deps:1.0.6’,
- ‘io.cucumber:cucumber-picocontainer:7.20.1’,
- ‘io.cucumber:cucumber-java:7.20.1’,
- ‘io.cucumber:cucumber-testng:7.20.1’,
- ‘me.jvt.cucumber:reporting-plugin:7.11.0’
I have tried to follow the documentation on gradle-pitest-plugin together with the multi-module example
What i was expecting was that it would recognize the cucumber tests (e.g. TestNgCucumberTest) and for each mutation execute the cucumber tests and the unit tests.
However i am running into some problems with the configuration:
I tried to configure it in the module-with-cucumber-features
Here it give an error: No mutations found
configure(project(':module-with-cucumber-features')) {
apply plugin: 'info.solidsoft.pitest'
dependencies {
implementation project(':module-with-java-code')
}
configurations { mutableCodeBase { transitive false } }
dependencies { mutableCodeBase project(':module-with-java-code') }
pitest {
mutators = ["ALL"]
mainSourceSets = [project(':module-with-java-code').sourceSets.main]
testSourceSets = [sourceSets.test]
targetTests = ['com.example.TestNgCucumberTest']
additionalMutableCodePaths = [configurations.mutableCodeBase.singleFile]
}
}
I tried to configure it in the root project
Here it give an error: “Could not get unknown property ‘implementation’ for configuration container for project ‘:module-with-java-code’ of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer”
configure(project(':module-with-cucumber-features')) {
apply plugin: 'info.solidsoft.pitest'
apply plugin: 'java'
dependencies {
implementation project(':module-with-java-code')
}
//Additional configuration to resolve :module-with-java-code project JAR as mutable code path for PIT
configurations {
mutableCodeBase { transitive false }
dependencies {
mutableCodeBase.extendsFrom(project(':module-with-java-code').configurations.implementation)
}
}
pitest {
timestampedReports = false
mainSourceSets = [project.sourceSets.main, project(':module-with-java-code').sourceSets.main]
//Generates deprecation warning in Gradle 5.6+
//Asked for recommendation: https://discuss.gradle.org/t/accessing-other-module-dependency-files-without-mutable-project-state-warnings/35048
additionalMutableCodePaths = configurations.mutableCodeBase.files
// additionalMutableCodePaths = project(':module-with-java-code').jar.outputs.files.getFiles() //Workaround
}
}
Daniël Gerritsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.