Skip to content

Commit

Permalink
[#319] Tweak nested property names for aggregated thresholds
Browse files Browse the repository at this point in the history
Also updated CHANGELOG and README.
  • Loading branch information
szpak committed Nov 25, 2022
1 parent ce904a0 commit d8a9b97
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 28 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## 1.9.11 - Unreleased

- Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267)
- Support for thresholds in aggregated metrics (requires PIT 1.9.9+) - [#319](https://github.com/szpak/gradle-pitest-plugin/issues/319) - PR by [pfoerd](https://github.com/Pfoerd)
- Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) - PR by [Carsten Otto](https://github.com/C-Otto)
- PIT 1.9.10 by default
- Minimal supported PIT version is 1.7.1 (due to "verbosity" flag used by default)
- Deprecated `verbose` flag - `verbosity` is much more versatile, especially when used from the Gradle plugin

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ subprojects {
exportLineCoverage = true
timestampedReports = false
...
reportAggregator { //since 1.9.11 - extra results validation, if needed
testStrengthThreshold.set(50) //simpler Groovy syntax (testStrengthThreshold = 50) does not seem to be supported for nested properties
mutationThreshold.set(40)
maxSurviving.set(3)
}
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ subprojects {
timestampedReports = false
exportLineCoverage = true
reportAggregator {
aggregatedTestStrengthThreshold.set(50)
aggregatedMutationThreshold.set(40)
aggregatedMaxSurviving.set(3)
testStrengthThreshold.set(50) //simpler Groovy syntax (testStrengthThreshold = 50) does not seem to be supported for nested properties
mutationThreshold.set(40)
maxSurviving.set(3)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class AggregateReportGenerator implements WorkAction<AggregateReportWor

log.info("Aggregated report ${parameters.reportFile.asFile.get().absolutePath}")

consumeIfPropertyIsSet(parameters.aggregatedTestStrengthThreshold) { threshold ->
consumeIfPropertyIsSet(parameters.testStrengthThreshold) { threshold ->
if (aggregationResult.testStrength < threshold) {
throw new GradleException(
"Aggregated test strength score of ${aggregationResult.testStrength} " +
Expand All @@ -48,7 +48,7 @@ abstract class AggregateReportGenerator implements WorkAction<AggregateReportWor
}
}

consumeIfPropertyIsSet(parameters.aggregatedMutationThreshold) { threshold ->
consumeIfPropertyIsSet(parameters.mutationThreshold) { threshold ->
if (aggregationResult.mutationCoverage < threshold) {
throw new GradleException(
"Aggregated mutation score of ${aggregationResult.mutationCoverage} " +
Expand All @@ -57,7 +57,7 @@ abstract class AggregateReportGenerator implements WorkAction<AggregateReportWor
}
}

consumeIfPropertyIsSet(parameters.aggregatedMaxSurviving) { threshold ->
consumeIfPropertyIsSet(parameters.maxSurviving) { threshold ->
if (aggregationResult.mutationsSurvived > threshold) {
throw new GradleException(
"Had ${aggregationResult.mutationsSurvived} " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ abstract class AggregateReportTask extends DefaultTask {

@Input
@Optional
final Property<Integer> aggregatedTestStrengthThreshold
final Property<Integer> testStrengthThreshold

@Input
@Optional
final Property<Integer> aggregatedMutationThreshold
final Property<Integer> mutationThreshold

@Input
@Optional
final Property<Integer> aggregatedMaxSurviving
final Property<Integer> maxSurviving

@Inject
abstract WorkerExecutor getWorkerExecutor()
Expand All @@ -97,9 +97,9 @@ abstract class AggregateReportTask extends DefaultTask {
lineCoverageFiles = of.fileCollection()
inputCharset = of.property(Charset)
outputCharset = of.property(Charset)
aggregatedTestStrengthThreshold = of.property(Integer)
aggregatedMutationThreshold = of.property(Integer)
aggregatedMaxSurviving = of.property(Integer)
testStrengthThreshold = of.property(Integer)
mutationThreshold = of.property(Integer)
maxSurviving = of.property(Integer)
}

@TaskAction
Expand All @@ -118,9 +118,9 @@ abstract class AggregateReportTask extends DefaultTask {
parameters.lineCoverageFiles.from(lineCoverageFiles)
parameters.inputCharset.set(this.inputCharset)
parameters.outputCharset.set(this.outputCharset)
parameters.aggregatedTestStrengthThreshold.set(this.aggregatedTestStrengthThreshold)
parameters.aggregatedMutationThreshold.set(this.aggregatedMutationThreshold)
parameters.aggregatedMaxSurviving.set(this.aggregatedMaxSurviving)
parameters.testStrengthThreshold.set(this.testStrengthThreshold)
parameters.mutationThreshold.set(this.mutationThreshold)
parameters.maxSurviving.set(this.maxSurviving)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ interface AggregateReportWorkParameters extends WorkParameters {
ConfigurableFileCollection getLineCoverageFiles()
Property<Charset> getInputCharset()
Property<Charset> getOutputCharset()
Property<Integer> getAggregatedTestStrengthThreshold()
Property<Integer> getAggregatedMutationThreshold()
Property<Integer> getAggregatedMaxSurviving()
Property<Integer> getTestStrengthThreshold()
Property<Integer> getMutationThreshold()
Property<Integer> getMaxSurviving()

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class PitestAggregatorPlugin implements Plugin<Project> {
findPluginExtension().ifPresent({ PitestPluginExtension extension ->
inputCharset.set(extension.inputCharset)
outputCharset.set(extension.outputCharset)
aggregatedTestStrengthThreshold.set(extension.reportAggregatorProperties.aggregatedTestStrengthThreshold)
aggregatedMutationThreshold.set(extension.reportAggregatorProperties.aggregatedMutationThreshold)
aggregatedMaxSurviving.set(extension.reportAggregatorProperties.aggregatedMaxSurviving)
testStrengthThreshold.set(extension.reportAggregatorProperties.testStrengthThreshold)
mutationThreshold.set(extension.reportAggregatorProperties.mutationThreshold)
maxSurviving.set(extension.reportAggregatorProperties.maxSurviving)
} as Consumer<PitestPluginExtension>) //Simplify with Groovy 3+
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import javax.inject.Inject
@CompileStatic
class ReportAggregatorProperties {

final Property<Integer> aggregatedTestStrengthThreshold
final Property<Integer> aggregatedMutationThreshold
final Property<Integer> aggregatedMaxSurviving
final Property<Integer> testStrengthThreshold
final Property<Integer> mutationThreshold
final Property<Integer> maxSurviving

@Inject
ReportAggregatorProperties(ObjectFactory objects) {
aggregatedTestStrengthThreshold = objects.property(Integer)
aggregatedMutationThreshold = objects.property(Integer)
aggregatedMaxSurviving = objects.property(Integer)
testStrengthThreshold = objects.property(Integer)
mutationThreshold = objects.property(Integer)
maxSurviving = objects.property(Integer)
}

}

0 comments on commit d8a9b97

Please sign in to comment.