summaryrefslogtreecommitdiffstats
path: root/docs/coverage.md
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2018-05-04 16:50:39 -0700
committerGirish Havaldar <hg0071052@techmahindra.com>2018-05-15 17:21:53 +0000
commitac134cb099afa6be09fbc5cdad5db0bcf7aee08a (patch)
treecbcdf280db9285edfe8c6e62e094c6c4c6db302e /docs/coverage.md
parentd4b81c05a255a847bbf7f08caebe032492ad2ca5 (diff)
Adding a docs folder under sms repo
WORK IN PROGRESS Adding a docs folder under sms Issue-ID: AAF-185 Change-Id: I5ee3560cfda2100ad5207bb7e98d5cb9472e1325 Signed-off-by: Girish Havaldar <hg0071052@techmahindra.com>
Diffstat (limited to 'docs/coverage.md')
-rw-r--r--docs/coverage.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/docs/coverage.md b/docs/coverage.md
new file mode 100644
index 0000000..6168342
--- /dev/null
+++ b/docs/coverage.md
@@ -0,0 +1,41 @@
+## Code Coverage Reports for Golang Applications ##
+
+This document covers how to generate HTML Code Coverage Reports for
+Golang Applications.
+
+#### Generate a test executable which calls your main()
+
+```sh
+$ go test -c -covermode=count -coverpkg ./...
+```
+
+#### Run the generated application to produce a new coverage report
+
+```sh
+$ ./sms.test -test.run "^TestMain$" -test.coverprofile=coverage.cov
+```
+
+#### Run your unit tests to produce their coverage report
+
+```sh
+$ go test -test.covermode=count -test.coverprofile=unit.out ./...
+```
+
+#### Merge the two coverage Reports
+
+```sh
+$ go get github.com/wadey/gocovmerge
+$ gocovmerge unit.out coverage.cov > all.out
+```
+
+#### Generate HTML Report
+
+```sh
+$ go tool cover -html all.out -o coverage.html
+```
+
+#### Generate Function Report
+
+```sh
+$ go tool cover -func all.out
+``` \ No newline at end of file