-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (43 loc) · 1.57 KB
/
Makefile
File metadata and controls
51 lines (43 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.PHONY: test test-v test-pkg test-example test-cover test-cover-usecase test-clean
# Default test target
test:
go test ./...
# Verbose test with test case names
test-v:
go test -v ./...
# Test specific package with verbose output
test-pkg:
@if [ "$(pkg)" = "" ]; then \
echo "Usage: make test-pkg pkg=<package_path>"; \
echo "Example: make test-pkg pkg=./pkg/mediator"; \
exit 1; \
fi
go test -v $(pkg)
# Test example package with verbose output
test-example:
go test -v ./example/...
# Run tests with coverage report for all packages
test-cover:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Run tests with coverage report for usecase package only
test-cover-usecase:
go test -coverprofile=coverage.out ./example/usecase/...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated for usecase package"
@go tool cover -func=coverage.out
# Clean test cache and coverage files
test-clean:
go clean -testcache
rm -f coverage.out coverage.html
# Help target
help:
@echo "Available targets:"
@echo " test - Run all tests"
@echo " test-v - Run all tests with verbose output"
@echo " test-pkg - Test specific package (usage: make test-pkg pkg=./pkg/mediator)"
@echo " test-example - Test example package"
@echo " test-cover - Run tests with coverage report for all packages"
@echo " test-cover-usecase - Run tests with coverage report for usecase package only"
@echo " test-clean - Clean test cache and coverage files"
@echo " help - Show this help message"