1
0
Files
nex/backend/Makefile
lanyuanxiaoyao 4e86adffb7 feat: 系统性改进后端测试体系
- 新增 6 个测试场景 (config load pipe, handler errors, service aggregation, engine degradation, openai decoder edges, negative tests)
- 更新测试工具规格 (mockgen, in-memory SQLite)
- 覆盖率目标从 >80% 提升至 >85%
- 新增 test-unit 和 test-integration Makefile 命令
- 新增死代码清理和 mockgen 需求
- 归档变更至 openspec/changes/archive/2026-04-22-improve-backend-testing/
2026-04-22 13:18:51 +08:00

58 lines
1.0 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.PHONY: build run test test-unit test-integration test-coverage clean migrate-up migrate-down migrate-status migrate-create lint generate deps
# 构建
build:
go build -o bin/server ./cmd/server
# 运行
run:
go run ./cmd/server
# 测试
test:
go test ./... -v
# 单元测试
test-unit:
go test ./internal/... ./pkg/... -v
# 集成测试
test-integration:
go test ./tests/... -v
# 测试覆盖率
test-coverage:
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# 清理
clean:
rm -rf bin/ coverage.out coverage.html
# 数据库迁移
migrate-up:
goose -dir migrations sqlite3 $(DB_PATH) up
migrate-down:
goose -dir migrations sqlite3 $(DB_PATH) down
migrate-status:
goose -dir migrations sqlite3 $(DB_PATH) status
migrate-create:
@read -p "Migration name: " name; \
goose -dir migrations create $$name sql
# 代码检查
lint:
go tool golangci-lint run ./...
# 安装依赖
deps:
go mod tidy
# 生成代码mock 等)
generate:
go generate ./...