Skip to content

Commit

Permalink
test: generate junit result for test-integration and add test-junit t…
Browse files Browse the repository at this point in the history
…arget
  • Loading branch information
chrischdi committed Aug 3, 2023
1 parent acffefd commit c2c3d68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ test: $(SETUP_ENVTEST) $(GOVC) ## Run unit tests
test-verbose: ## Run unit tests with verbose flag
$(MAKE) test TEST_ARGS="$(TEST_ARGS) -v"

.PHONY: test-junit
test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) $(GOVC) ## Run unit tests
set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" GOVC_BIN_PATH=$(GOVC) go test -json ./apis/... ./controllers/... ./pkg/... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout
$(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.xml --raw-command cat $(ARTIFACTS)/junit.stdout
exit $$(cat $(ARTIFACTS)/junit.exitcode)

.PHONY: test-cover
test-cover: ## Run unit tests and generate a coverage report
$(MAKE) test TEST_ARGS="$(TEST_ARGS) -coverprofile=coverage.out"
Expand Down
6 changes: 5 additions & 1 deletion test/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"time"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
vmoprv1 "github.com/vmware-tanzu/vm-operator-api/api/v1alpha1"
Expand Down Expand Up @@ -179,7 +181,9 @@ type WorkerComponents struct {

func TestCAPV(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "CAPV Supervisor integration tests")
junitPath := filepath.Join(artifactFolder, fmt.Sprintf("junit.integration_suite.%d.xml", config.GinkgoConfig.ParallelNode))
junitReporter := reporters.NewJUnitReporter(junitPath)
RunSpecsWithCustomReporters(t, "CAPV Supervisor integration tests", []Reporter{junitReporter})
}

var (
Expand Down

0 comments on commit c2c3d68

Please sign in to comment.