Skip to content

Commit

Permalink
Merge pull request #193 from gw-kit/feature/170-fix-textual-report-or…
Browse files Browse the repository at this point in the history
…dering

#170 order textual reports by branches, lines, instructions
  • Loading branch information
SurpSG authored Dec 17, 2024
2 parents 2b90a3b + 01efe61 commit ebf9da0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Changed
- Now the `aggregated` view is disabled by default if there is only one view is configured.
- Textual reports now sorted by DESC branches, lines, instructions.

### Fixed
- Fix `deltaCoverage*` task creation for custom view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ internal object TextualReportFacade {
val rawCoverageData: List<RawCoverageData> = buildContext.coverageDataProvider.obtainData()
val coverageDataValues: List<List<String>> =
rawCoverageData
.sortedByDescending { it.lines.ratio }
.sortedWith(
compareBy<RawCoverageData>(
{ it.branches.ratio },
{ it.lines.ratio },
{ it.instr.ratio },
).reversed()
)
.asSequence()
.map { it.toValuesCollection(buildContext) }
.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,18 @@ class TextualReportFacadeTest {
@Test
fun `generateReport should render report`() {
val rawCoverageData = listOf(
RawCoverageData.newBlank {
aClass = "class3"
branches(1, 2); lines(3, 4); instr(8, 10)
},
RawCoverageData.newBlank {
aClass = "class1"
branches(1, 2)
lines(3, 4)
instr(5, 6)
branches(1, 2); lines(3, 4); instr(5, 6)
},
RawCoverageData.newBlank {
aClass = "class2"
branches(5, 6)
lines(7, 8)
instr(9, 10)
}
branches(5, 6); lines(7, 8); instr(9, 10)
},
)
val stream = ByteArrayOutputStream()
val buildContext = TextualReportFacade.BuildContext {
Expand All @@ -186,7 +186,7 @@ class TextualReportFacadeTest {
outputStream = stream

targetCoverage(CoverageEntity.INSTRUCTION, 0.95)
targetCoverage(CoverageEntity.BRANCH, 0.75)
targetCoverage(CoverageEntity.BRANCH, 0.7)
targetCoverage(CoverageEntity.LINE, 0.9)
}

Expand All @@ -199,8 +199,9 @@ class TextualReportFacadeTest {
|--------------|----------|----------|----------|
| class2 | 87.50% | 83.33% | 90% |
| class1 | 75% | 50% | 83.33% |
| Total | 🔴 83.33% | 🟢 75% | 🔴 87.50% |
| Min expected | 90% | 75% | 95% |
| class3 | 75% | 50% | 80% |
| Total | 🔴 81.25% | 🟢 70% | 🔴 84.62% |
| Min expected | 90% | 70% | 95% |
""".trimIndent()
stream.toString() shouldBe expectedReport
Expand Down

0 comments on commit ebf9da0

Please sign in to comment.