Skip to content

Commit

Permalink
coverage number needs only test names
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed Apr 28, 2021
1 parent b9dbffa commit c3d75bc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pitest-entry/src/main/java/org/pitest/coverage/CoverageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -38,6 +37,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toCollection;
Expand Down Expand Up @@ -147,7 +147,7 @@ private void addTestsToBlockMap(final TestInfo ti, InstructionLocation each) {

@Override
public BigInteger getCoverageIdForClass(final ClassName clazz) {
final Map<ClassLine, Set<TestInfo>> coverage = getLineCoverageForClassName(clazz);
final Collection<TestInfo> coverage = getTestsForClass(clazz);
if (coverage.isEmpty()) {
return BigInteger.ZERO;
}
Expand Down Expand Up @@ -181,11 +181,11 @@ public CoverageSummary createSummary() {
return new CoverageSummary(numberOfLines(), coveredLines());
}

private BigInteger generateCoverageNumber(
final Map<ClassLine, Set<TestInfo>> coverage) {
private BigInteger generateCoverageNumber(Collection<TestInfo> coverage) {
BigInteger coverageNumber = BigInteger.ZERO;
final Set<ClassName> testClasses = new HashSet<>();
FCollection.flatMapTo(coverage.values(), testsToClassName(), testClasses);
Set<ClassName> testClasses = coverage.stream()
.map(TestInfo.toDefiningClassName())
.collect(Collectors.toSet());

for (final ClassInfo each : this.code.getClassInfo(testClasses)) {
coverageNumber = coverageNumber.add(each.getDeepHash());
Expand All @@ -194,10 +194,6 @@ private BigInteger generateCoverageNumber(
return coverageNumber;
}

private Function<Set<TestInfo>, Iterable<ClassName>> testsToClassName() {
return a -> FCollection.map(a, TestInfo.toDefiningClassName());
}

private static Function<ClassInfo, String> keyFromClassInfo() {

return c -> keyFromSourceAndPackage(c.getSourceFileName(), c.getName()
Expand Down

0 comments on commit c3d75bc

Please sign in to comment.