Skip to content

Commit

Permalink
Merge pull request #1157 from hcoles/bug/coverage_not_filtered
Browse files Browse the repository at this point in the history
report only target code lines
  • Loading branch information
hcoles authored Feb 27, 2023
2 parents 4d593e9 + 0bc4337 commit 9f32e36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package org.pitest.mutationtest.tooling;

import org.pitest.bytecode.analysis.ClassTree;
import org.pitest.classinfo.CachingByteArraySource;
import org.pitest.classinfo.ClassByteArraySource;
import org.pitest.classinfo.ClassInfo;
Expand Down Expand Up @@ -201,8 +200,8 @@ private ReportCoverage transformCoverage(ReportCoverage coverageData) {
}

private CoverageSummary createSummary(ReportCoverage modifiedCoverage) {
int numberOfCodeLines = this.code.codeTrees()
.map(ClassTree::numberOfCodeLines)
int numberOfCodeLines = this.code.getCodeUnderTestNames().stream()
.map(c -> modifiedCoverage.getCodeLinesForClass(c).getNumberOfCodeLines())
.reduce(0, Integer::sum);

int coveredLines = this.code.getCodeUnderTestNames().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.pitest.classinfo.ClassName;
import org.pitest.classinfo.HierarchicalClassId;
import org.pitest.classpath.CodeSource;
import org.pitest.coverage.ClassLines;
import org.pitest.coverage.CoverageDatabase;
import org.pitest.coverage.CoverageGenerator;
import org.pitest.help.Help;
Expand Down Expand Up @@ -158,6 +159,7 @@ public void shouldRecordClassPath() {
Collections.singleton(clazz));
when(this.code.getClassInfo(anyCollection())).thenReturn(
Collections.singletonList(foo));
when(this.coverageDb.getCodeLinesForClass(clazz)).thenReturn(new ClassLines(clazz, Collections.emptySet()));

createAndRunTestee();

Expand Down Expand Up @@ -198,6 +200,7 @@ public void shouldReportMutationsFoundWhenSomeDetected() {
when(this.mutater.findMutations(foo)).thenReturn(aMutantIn(Foo.class));
when(this.code.getCodeUnderTestNames()).thenReturn(
Collections.singleton(foo));
when(this.coverageDb.getCodeLinesForClass(foo)).thenReturn(new ClassLines(foo, Collections.emptySet()));
final CombinedStatistics actual = createAndRunTestee();
assertEquals(1, actual.getMutationStatistics().getTotalMutations());
}
Expand Down

0 comments on commit 9f32e36

Please sign in to comment.