Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
gocov: report total coverage as 0.00% if reached and statements are zero
Browse files Browse the repository at this point in the history
Fixes #84
  • Loading branch information
thanabodee-c committed Jun 28, 2019
1 parent b6eca66 commit 0c17229
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gocov/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"fmt"
"io"
"io/ioutil"
"math"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -136,6 +137,9 @@ func (r *report) printTotalCoverage(w io.Writer) {
}

coveragePercentage := float64(totalReached) / float64(totalStatements) * 100
if math.IsNaN(coveragePercentage) {
coveragePercentage = 0
}
fmt.Fprintf(w, "Total Coverage: %.2f%% (%d/%d)", coveragePercentage, totalReached, totalStatements)
fmt.Fprintln(w)
}
Expand Down

0 comments on commit 0c17229

Please sign in to comment.