diff --git a/formatters/clover/clover_test.go b/formatters/clover/clover_test.go index ce0f0061..399651d6 100644 --- a/formatters/clover/clover_test.go +++ b/formatters/clover/clover_test.go @@ -54,3 +54,26 @@ func Test_Parse_Without_Package(t *testing.T) { r.Equal(0, sf.Coverage[38].Int) r.Equal(5, sf.Coverage[62].Int) } + +func Test_Parse_With_Metrics(t *testing.T) { + gb := env.GitBlob + defer func() { env.GitBlob = gb }() + env.GitBlob = func(s string, c *object.Commit) (string, error) { + return s, nil + } + + r := require.New(t) + + f := &Formatter{Path: "./example_with_metrics.xml"} + rep, err := f.Format() + r.NoError(err) + r.Len(rep.SourceFiles, 4) + + sf := rep.SourceFiles["/Users/markbates/Dropbox/development/php-test-reporter/src/ConsoleCommands/SelfUpdateCommand.php"] + r.InDelta(15.2, sf.CoveredPercent, 1) + r.Len(sf.Coverage, 80) + r.False(sf.Coverage[2].Valid) + r.True(sf.Coverage[43].Valid) + r.Equal(0, sf.Coverage[38].Int) + r.Equal(5, sf.Coverage[62].Int) +} diff --git a/formatters/clover/example_with_metrics.xml b/formatters/clover/example_with_metrics.xml new file mode 100644 index 00000000..c09b63e3 --- /dev/null +++ b/formatters/clover/example_with_metrics.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +