You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-24Lines changed: 26 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,29 +28,37 @@ List available themes|`-lt`|`1.2.0`
28
28
Render with a specific theme|`-t <theme>`|`1.2.0`
29
29
New `kit` theme |`-t kit`|`1.3.0`
30
30
Put lower coverage functions on top|`-r`|`1.3.1`
31
+
Only show functions whose coverage is smaller than a max threshold|`-cmax`|`1.4.0`
32
+
Only show functions whose coverage is greater than a min threshold|`-cmin`|`1.4.0`
31
33
32
34
## Usage
33
35
34
36
```
35
-
$ gocov-html -h
36
-
Usage of ./gocov-html:
37
+
Usage of gocov-html:
38
+
-cmax uint
39
+
only show functions whose coverage is less than cmax (default 100)
40
+
-cmin uint
41
+
only show functions whose coverage is more than cmin
37
42
-d output CSS of default theme
38
43
-lt
39
44
list available themes
45
+
-r put lower coverage functions on top
40
46
-s string
41
47
path to custom CSS file
42
48
-t string
43
49
theme to use for rendering (default "golang")
44
50
-v show program version
45
51
```
46
52
47
-
`gocov-html` can read a JSON file or read from standard input:
53
+
## Examples
54
+
55
+
Generate code coverage for the `strings` package then generate an HTML report:
48
56
```
49
57
$ gocov test strings | gocov-html > strings.html
50
58
ok strings 0.700s coverage: 98.1% of statements
51
59
```
52
60
53
-
Several packages can be tested at once and added to a single report. Let's test the `fmt`, `math` and `io` packages:
61
+
Merge several coverage stats for different packages into a single report:
54
62
```
55
63
$ gocov test fmt math io | gocov-html > report.html
56
64
ok fmt 0.045s coverage: 95.2% of statements
@@ -60,29 +68,23 @@ ok io 0.024s coverage: 88.2% of statements
60
68
61
69
In this case, the generated report will have an *overview* section with stats per package along with the global coverage percentage. This section may be rendered depending on the theme used. The `golang` (default) theme displays it.
62
70
63
-
The generated HTML content comes along with a default embedded CSS. However a custom stylesheet can be used with the `-s` flag:
71
+
List all available themes:
72
+
```
73
+
$ gocov-html -lt
74
+
golang -- original golang theme (default)
75
+
kit -- AdminKit theme
76
+
```
77
+
78
+
Generate a report using a specific theme with `-t`:
64
79
```
65
-
$ gocov test net/http | gocov-html -s mystyle.css > http.html
80
+
$ gocov test io | gocov-html -t kit > io.html
66
81
```
67
82
68
-
As of version 1.2,
69
-
- A `-d` flag is available to write the defaut stylesheet to the standard output. This is provided for convenience and easy editing:
70
-
```
71
-
$ gocov-html -d > newstyle.css
72
-
... edit newstyle.css ...
73
-
$ gocov test strings | gocov-html -s newstyle.css > http.html
74
-
```
75
-
- The content of the stylesheet given to `-s` is embedded into the final HTML document
76
-
- Theming capabilities are available (to go further than just using a CSS file) through the use of Go templates.
77
-
- Use the `-lt` flag to list available themes:
78
-
```
79
-
$ gocov-html -lt
80
-
golang -- original golang theme (default)
81
-
```
82
-
- Generate a report using a specific theme with `-t`:
83
-
```
84
-
$ gocov test io | gocov-html -t golang > io.html
85
-
```
83
+
Only show functions whose code coverage is lower than 90% for the `strings` package:
84
+
```
85
+
$ gocov test strings|./gocov-html -cmax 90 > strings.html
86
+
```
87
+
In this example, only 5 matches are added to the report.
0 commit comments