Skip to content

Commit

Permalink
Fix, skipped mutations should count towards total mutations not
Browse files Browse the repository at this point in the history
duplicated mutations
  • Loading branch information
zimmski committed Oct 28, 2016
1 parent 0c2b0fb commit 7ccb9f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion cmd/go-mutesting/main.go
Expand Up @@ -152,6 +152,20 @@ type mutationStats struct {
skipped int
}

func (ms *mutationStats) Score() float64 {
total := ms.Total()

if total == 0 {
return 0.0
}

return float64(ms.passed) / float64(total)
}

func (ms *mutationStats) Total() int {
return ms.passed + ms.failed + ms.skipped
}

func mainCmd(args []string) int {
var opts = &options{}
var mutationBlackList = map[string]struct{}{}
Expand Down Expand Up @@ -317,7 +331,7 @@ MUTATOR:
}

if !opts.Exec.NoExec {
fmt.Printf("The mutation score is %f (%d passed, %d failed, %d duplicated, %d skipped, total is %d)\n", float64(stats.passed)/float64(stats.passed+stats.failed), stats.passed, stats.failed, stats.duplicated, stats.skipped, stats.passed+stats.failed+stats.duplicated+stats.skipped)
fmt.Printf("The mutation score is %f (%d passed, %d failed, %d duplicated, %d skipped, total is %d)\n", stats.Score(), stats.passed, stats.failed, stats.duplicated, stats.skipped, stats.Total())
} else {
fmt.Println("Cannot do a mutation testing summary since no exec command was executed.")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/go-mutesting/main_test.go
Expand Up @@ -15,7 +15,7 @@ func TestMain(t *testing.T) {
"../../example",
[]string{"--debug", "--exec-timeout", "1"},
returnOk,
"The mutation score is 0.538462 (7 passed, 6 failed, 9 duplicated, 0 skipped, total is 22)",
"The mutation score is 0.538462 (7 passed, 6 failed, 9 duplicated, 0 skipped, total is 13)",
)
}

Expand All @@ -25,7 +25,7 @@ func TestMainRecursive(t *testing.T) {
"../../example",
[]string{"--debug", "--exec-timeout", "1", "./..."},
returnOk,
"The mutation score is 0.571429 (8 passed, 6 failed, 9 duplicated, 0 skipped, total is 23)",
"The mutation score is 0.571429 (8 passed, 6 failed, 9 duplicated, 0 skipped, total is 14)",
)
}

Expand All @@ -35,7 +35,7 @@ func TestMainFromOtherDirectory(t *testing.T) {
"../..",
[]string{"--debug", "--exec-timeout", "1", "github.com/zimmski/go-mutesting/example"},
returnOk,
"The mutation score is 0.538462 (7 passed, 6 failed, 9 duplicated, 0 skipped, total is 22)",
"The mutation score is 0.538462 (7 passed, 6 failed, 9 duplicated, 0 skipped, total is 13)",
)
}

Expand Down

0 comments on commit 7ccb9f3

Please sign in to comment.