Skip to content

Commit

Permalink
Enable code coverage for system tests (#970)
Browse files Browse the repository at this point in the history
This commit adds possibility to build kiali which can
produce code coverage report even for system tests which run against
kiali deployed in OpenShift. Note this does not do anything
for code coverage of unit tests.
  • Loading branch information
FilipB authored and jmazzitelli committed Apr 26, 2019
1 parent d6614ea commit e3772de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ format:
gofmt -w $$gofile; \
done

## build-system-test: Building executable for system tests with code coverage enabled
build-system-test:
@echo Building executable for system tests with code coverage enabled
go test -c -covermode=count -coverpkg ./... -o ${GOPATH}/bin/kiali

## build-test: Run tests and installing test dependencies, excluding third party tests under vendor. Runs `go test -i` internally
build-test:
@echo Building and installing test dependencies to help speed up test runs.
Expand Down
20 changes: 20 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

// This file is mandatory as otherwise the kiali binary for system tests is not generated correctly.
import (
"flag"
"testing"
)

var systemTest *bool

func init() {
systemTest = flag.Bool("systemTest", false, "Set to true when running system tests")
}

// Test started when the test binary is started. Only calls main.
func TestSystem(t *testing.T) {
if *systemTest {
main()
}
}

0 comments on commit e3772de

Please sign in to comment.