From b9c51411df695f6bb76b6fda4dadc4b4a4a1d44f Mon Sep 17 00:00:00 2001 From: hau Date: Fri, 7 Aug 2020 12:50:49 +0700 Subject: [PATCH] add go coverage --- Development/Go/testing.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Development/Go/testing.md b/Development/Go/testing.md index d425bf1..a84e264 100644 --- a/Development/Go/testing.md +++ b/Development/Go/testing.md @@ -1,5 +1,18 @@ # [testing](https://golang.org/pkg/testing/) +## Coverage + +```sh +# Write a coverage profile +go test -coverprofile=coverage.out ./... + +# Coverage +go tool cover -func=coverage.out + +# Coverage with HTML +go tool cover -html=coverage.out +``` + ## Benchmark Any benchmark should be careful to prevent **compiler optimization**.