coverage percentage: assume 0/0 to be 100% (IDEA-160268)

This commit is contained in:
Anna Kozlova
2016-08-25 21:03:40 +03:00
parent 8dd45d8f2c
commit ca410786df
2 changed files with 3 additions and 2 deletions
@@ -232,7 +232,8 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator {
}
private static String getPercentage(int covered, int total) {
return (int)((double)covered /total * 100) +"% (" + covered + "/" + total + ")";
final int percentage = total == 0 ? 100 : (int)((double)covered / total * 100);
return percentage + "% (" + covered + "/" + total + ")";
}
public static PackageAnnotator.SummaryCoverageInfo merge(@Nullable final PackageAnnotator.SummaryCoverageInfo info,
@@ -470,7 +470,7 @@ public class PackageAnnotator {
classCoverageInfo.totalMethodCount += toplevelClassCoverageInfo.totalMethodCount;
classCoverageInfo.coveredMethodCount += toplevelClassCoverageInfo.coveredMethodCount;
if (toplevelClassCoverageInfo.coveredMethodCount > 0) {
if (toplevelClassCoverageInfo.getCoveredLineCount() > 0) {
classCoverageInfo.coveredClassCount++;
}
}