From 8002995147b6376f7fdb598f09831e7b413171e1 Mon Sep 17 00:00:00 2001 From: rameshthoomu Date: Fri, 5 Aug 2016 09:33:47 -0400 Subject: [PATCH] go unit test code coverage report in jenkins Implementing go unit test coverage in jenkins build process using cobertura jenkins plugin and gocovxml. Updated go unit test command to generate xml file using gocov-xml package. Change-Id: I0f516974392ffcec817ef126078d35dc8d78f71f Signed-off-by: rameshthoomu --- .gitignore | 1 + gotools/Makefile | 4 +++- scripts/goUnitTests.sh | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c8e327b6e60..23147526e14 100755 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ bddtests/coverage go-carpet-coverage* # make node-sdk copied files sdk/node/lib/protos/* +report.xml diff --git a/gotools/Makefile b/gotools/Makefile index 1d318f2b53e..23ff0691aa5 100644 --- a/gotools/Makefile +++ b/gotools/Makefile @@ -16,7 +16,7 @@ # under the License. # -GOTOOLS = golint govendor goimports protoc-gen-go ginkgo gomega +GOTOOLS = golint govendor goimports protoc-gen-go ginkgo gomega gocov gocovxml GOTOOLS_BIN = $(patsubst %,$(GOPATH)/bin/%, $(GOTOOLS)) # go tool->path mapping @@ -25,6 +25,8 @@ go.fqp.golint := github.com/golang/lint/golint go.fqp.goimports := golang.org/x/tools/cmd/goimports go.fqp.ginkgo := github.com/onsi/ginkgo/ginkgo go.fqp.gomega := github.com/onsi/gomega +go.fqp.gocov := github.com/axw/gocov/... +go.fqp.gocovxml := github.com/AlekSi/gocov-xml all: $(GOTOOLS_BIN) diff --git a/scripts/goUnitTests.sh b/scripts/goUnitTests.sh index 824841dad3c..bf2f7def2c6 100755 --- a/scripts/goUnitTests.sh +++ b/scripts/goUnitTests.sh @@ -19,4 +19,4 @@ trap cleanup 0 echo "DONE!" echo "Running tests..." -go test -cover -p 1 -timeout=20m $PKGS +gocov test $PKGS -p 1 -timeout=20m | gocov-xml > report.xml