@@ -51,14 +51,32 @@ install: build ## Build and install the provider locally
5151.PHONY : test
5252test : # # Run unit tests
5353 @echo " $( GREEN) Running unit tests...$( NC) "
54- $(GOTEST ) -v -cover -coverprofile=coverage.out ./internal/...
54+ @if command -v gotestsum > /dev/null 2>&1 ; then \
55+ echo " $( CYAN) Using gotestsum for enhanced test output...$( NC) " ; \
56+ gotestsum --junitfile junit.xml --format testname -- -v -cover -coverprofile=coverage.out ./internal/...; \
57+ else \
58+ $(GOTEST ) -v -cover -coverprofile=coverage.out ./internal/...; \
59+ fi
5560 @echo " $( GREEN) Unit tests complete!$( NC) "
5661
5762.PHONY : test-coverage
5863test-coverage : test # # Run tests and show coverage report
5964 @echo " $( GREEN) Generating coverage report...$( NC) "
6065 @go tool cover -html=coverage.out -o coverage.html
6166 @echo " $( GREEN) Coverage report generated: coverage.html$( NC) "
67+ @if [ -f junit.xml ]; then \
68+ echo " $( GREEN) JUnit test report generated: junit.xml$( NC) " ; \
69+ fi
70+
71+ .PHONY : test-junit
72+ test-junit : # # Run tests with JUnit XML output
73+ @echo " $( GREEN) Running tests with JUnit output...$( NC) "
74+ @if ! command -v gotestsum > /dev/null 2>&1 ; then \
75+ echo " $( YELLOW) Installing gotestsum...$( NC) " ; \
76+ go install gotest.tools/gotestsum@latest; \
77+ fi
78+ @gotestsum --junitfile junit.xml --format testname -- -v -cover -coverprofile=coverage.out ./internal/...
79+ @echo " $( GREEN) Tests complete! JUnit report: junit.xml$( NC) "
6280
6381.PHONY : test-acc
6482test-acc : # # Run acceptance tests (requires POCKETID_BASE_URL and POCKETID_API_TOKEN)
@@ -134,7 +152,7 @@ docs-preview: ## Preview documentation in browser
134152clean : # # Clean build artifacts
135153 @echo " $( GREEN) Cleaning build artifacts...$( NC) "
136154 @rm -f $(BINARY_NAME )
137- @rm -f coverage.out coverage.html
155+ @rm -f coverage.out coverage.html junit.xml
138156 @rm -rf dist/
139157 @echo " $( GREEN) Clean complete!$( NC) "
140158
@@ -201,6 +219,18 @@ test-integration: ## Run integration tests against live Pocket-ID instance
201219 @cd test && terraform init && terraform apply -auto-approve
202220 @echo " $( GREEN) Integration tests complete!$( NC) "
203221
222+ .PHONY : test-ci
223+ test-ci : # # Run tests in CI format with JUnit output
224+ @echo " $( GREEN) Running tests in CI format...$( NC) "
225+ @if ! command -v gotestsum > /dev/null 2>&1 ; then \
226+ echo " $( YELLOW) Installing gotestsum...$( NC) " ; \
227+ go install gotest.tools/gotestsum@latest; \
228+ fi
229+ @gotestsum --junitfile junit.xml --format standard-verbose -- -v -race -cover -coverprofile=coverage.out ./internal/...
230+ @echo " $( GREEN) CI tests complete!$( NC) "
231+ @echo " Coverage report: coverage.out"
232+ @echo " JUnit report: junit.xml"
233+
204234.PHONY : test-cleanup
205235test-cleanup : # # Clean up integration test resources
206236 @echo " $( GREEN) Cleaning up test resources...$( NC) "
0 commit comments