-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathclover_test.go
79 lines (64 loc) · 2.04 KB
/
clover_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package clover
import (
"testing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"github.com/codeclimate/test-reporter/env"
"github.com/stretchr/testify/require"
)
func Test_Parse(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.xml"}
rep, err := f.Format()
r.NoError(err)
r.Len(rep.SourceFiles, 13)
sf := rep.SourceFiles["/Users/markbates/Dropbox/development/php-test-reporter/src/TestReporter/Entity/CiInfo.php"]
r.InDelta(91.78, sf.CoveredPercent, 1)
r.Len(sf.Coverage, 194)
r.False(sf.Coverage[51].Valid)
r.True(sf.Coverage[54].Valid)
r.Equal(4, sf.Coverage[53].Int)
r.Equal(0, sf.Coverage[55].Int)
}
func Test_Parse_Without_Package(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_without_package.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)
}
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)
}