Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: generate a jUnit file per test suite (#907) (#909)
Browse files Browse the repository at this point in the history
* fix: generate a jUnit file per test suite

* chore: move reports setup goal to a common Makefile
  • Loading branch information
mdelapenya committed Mar 17, 2021
1 parent 68b95ca commit 36bc9a0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
7 changes: 2 additions & 5 deletions .ci/scripts/build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ mkdir -p $(pwd)/outputs

go get -v -u gotest.tools/gotestsum

# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output
GOTESTSUM_JUNITFILE="$(pwd)/outputs/TEST-unit-cli.xml" make -C cli install test

# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output
GOTESTSUM_JUNITFILE="$(pwd)/outputs/TEST-unit-e2e.xml" make -C e2e unit-test
make -C cli install test
make -C e2e unit-test
6 changes: 4 additions & 2 deletions cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Get current directory of a Makefile: https://stackoverflow.com/a/23324703
ROOT_DIR:=$(CURDIR)

include ../commons.mk

TEST_TIMEOUT?=5m

GO_IMAGE?='golang'
Expand Down Expand Up @@ -41,5 +43,5 @@ sync-integrations:
OP_LOG_LEVEL=${LOG_LEVEL} go run main.go sync integrations --delete

.PHONY: test
test:
gotestsum --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./...
test: test-report-setup
gotestsum --junitfile "$(PWD)/outputs/TEST-unit-cli.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./...
4 changes: 4 additions & 0 deletions commons.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Prepare junit build context
.PHONY: test-report-setup
test-report-setup:
mkdir -p $(PWD)/outputs
16 changes: 13 additions & 3 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../commons.mk

SUITE?=metricbeat
TAGS?=
DEVELOPER_MODE?=false
Expand Down Expand Up @@ -101,9 +103,17 @@ notice:
-depsOut ""

.PHONY: unit-test
unit-test:
gotestsum --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./...
cd _suites && gotestsum --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./...
unit-test: test-report-setup unit-test-e2e unit-test-suite-fleet unit-test-suite-helm unit-test-suite-metricbeat

# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output
.PHONY: unit-test-e2e
unit-test-e2e:
gotestsum --junitfile "$(PWD)/outputs/TEST-unit-e2e.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./...

# See https://pkg.go.dev/gotest.tools/gotestsum/#readme-junit-xml-output
.PHONY: unit-test-suite-%
unit-test-suite-%:
cd _suites/$* && gotestsum --junitfile "$(PWD)/outputs/TEST-unit-e2e-$*.xml" --format testname -- -count=1 -timeout=$(TEST_TIMEOUT) ./...

## Test examples

Expand Down

0 comments on commit 36bc9a0

Please sign in to comment.