From 24b469c511fd34fa6c7f5467879849a981aee3a3 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Tue, 19 Nov 2024 19:52:24 +0100 Subject: [PATCH] added junit.xml output --- Makefile | 10 ++++++++-- filtertestjson | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 filtertestjson diff --git a/Makefile b/Makefile index c2fde98..7b43608 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,16 @@ vet: fmt go vet ./... test: build - go test -count=1 ${TESTFLAGS} ./pkg/... ./cmd/... + mkdir -p testout + go test -count=1 -coverprofile=testout/coverage.out -json ${TESTFLAGS} ./pkg/... ./cmd/... 2>&1 | \ + tee testout/tests.json | sh filtertestjson + go-junit-report < testout/tests.json > testout/junit.xml integrationtest: build - go test -count=1 ${TESTFLAGS} ./integrationtest/... + mkdir -p testout + go test -count=1 ${TESTFLAGS} ./integrationtest/... -json 2>&1 | \ + tee testou8t/integrationtests.json | sh filtertestjson + go-junit-report < testout/integrationtests.json > testout/integrationtest.xml build: generate vet mkdir -p bin diff --git a/filtertestjson b/filtertestjson new file mode 100644 index 0000000..25fddf6 --- /dev/null +++ b/filtertestjson @@ -0,0 +1,12 @@ +#!/bin/bash + + +jq -r ' + select(.Action != "outputx") | + if .Action == "fail" then "❌ FAIL: \(.Package) \(.Test // "")" + elif .Action == "pass" then "✅ PASS: \(.Package) \(.Test // "")" + elif .Action == "run" then "▶️ RUN: \(.Package) \(.Test // "")" + else " \(.Output // "" | rtrimstr("\n") )" + end +' +