Skip to content

Commit 5574fce

Browse files
authored
junit-report (#340)
1 parent a576624 commit 5574fce

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ cmd/clusterctl/examples/ibmcloud/provider-component/user-data/ubuntu/worker-user
2222
# test coverage out
2323
cover.out
2424

25+
# JUnit test output from ginkgo unit tests
26+
junit*.xml
27+
2528
# dep ensured 3rd code
2629
vendor/sigs.k8s.io/cluster-api/docs/book/*.json

controllers/suite_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import (
2121
"testing"
2222

2323
. "github.com/onsi/ginkgo"
24+
"github.com/onsi/ginkgo/reporters"
2425
. "github.com/onsi/gomega"
2526
"k8s.io/client-go/kubernetes/scheme"
2627
"k8s.io/client-go/rest"
2728
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
2829
"sigs.k8s.io/controller-runtime/pkg/client"
2930
"sigs.k8s.io/controller-runtime/pkg/envtest"
30-
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
3131

3232
infrastructurev1alpha4 "github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/api/v1alpha4"
3333
// +kubebuilder:scaffold:imports
@@ -42,10 +42,8 @@ var testEnv *envtest.Environment
4242

4343
func TestAPIs(t *testing.T) {
4444
RegisterFailHandler(Fail)
45-
46-
RunSpecsWithDefaultAndCustomReporters(t,
47-
"Controller Suite",
48-
[]Reporter{printer.NewlineReporter{}})
45+
junitReporter := reporters.NewJUnitReporter("junit-controller.xml")
46+
RunSpecsWithDefaultAndCustomReporters(t, "Controller Suite", []Reporter{junitReporter})
4947
}
5048

5149
var _ = BeforeSuite(func(done Done) {

scripts/ci-test.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,29 @@ REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2222
# shellcheck source=../hack/ensure-go.sh
2323
source "${REPO_ROOT}/hack/ensure-go.sh"
2424

25+
# Directory to store JUnit XML test report.
26+
JUNIT_REPORT_DIR=${JUNIT_REPORT_DIR:-}
27+
28+
# If JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match.
29+
if [[ -z "${JUNIT_REPORT_DIR:-}" && -n "${ARTIFACTS:-}" ]]; then
30+
JUNIT_REPORT_DIR="${ARTIFACTS}"
31+
fi
32+
33+
#Add Junit test reports to ARTIFACTS directory.
34+
function addJunitFiles(){
35+
declare -a junitFileList
36+
readarray -t junitFileList <<< "$(find "${REPO_ROOT}" -name 'junit-*.xml')"
37+
38+
for i in "${junitFileList[@]}"
39+
do
40+
mv "${i}" "${ARTIFACTS}"
41+
done
42+
}
43+
2544
cd "${REPO_ROOT}" && \
2645
source ./scripts/fetch_ext_bins.sh && \
2746
fetch_tools && \
2847
setup_envs && \
2948
make generate lint test
49+
50+
addJunitFiles

0 commit comments

Comments
 (0)