Skip to content

Commit b263f5e

Browse files
committed
chore(test): add comprehensive test coverage infrastructure with coverage reporting tools
This commit introduces a complete test coverage infrastructure including coverage reporting tools, configuration files, and enhanced Makefile targets for comprehensive test coverage analysis. The changes include: - Adding `scripts/check_coverage.py` to handle coverage analysis and threshold checking - Creating `coverage.json` to store coverage data - Adding `coverage.yaml` for coverage configuration with line and branch coverage thresholds - Enhancing Makefile with comprehensive coverage targets (test, test-unit, test-e2e, coverage, coverage-full, coverage-check, etc.) // 此提交引入了一个完整的测试覆盖基础设施,包括覆盖报告工具、配置文件和增强的 Makefile 目标,用于全面的测试覆盖分析。 更改包括: - 添加 `scripts/check_coverage.py` 来处理覆盖分析和阈值检查 - 创建 `coverage.json` 来存储覆盖数据 - 添加 `coverage.yaml` 用于覆盖配置,包含行和分支覆盖阈值 - 增强 Makefile,添加全面的覆盖目标(test、test-unit、test-e2e、coverage、coverage-full、coverage-check 等) Change-Id: I6561fa6c9f1cc37578fc246b5a2f05fe33463f07 Signed-off-by: OhYee <[email protected]>
1 parent fdcea19 commit b263f5e

File tree

4 files changed

+8105
-0
lines changed

4 files changed

+8105
-0
lines changed

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,63 @@ install-deps:
122122
--dev \
123123
--all-extras \
124124
-i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
125+
126+
# ============================================================================
127+
# 测试和覆盖率
128+
# ============================================================================
129+
130+
.PHONY: test
131+
test: ## 运行所有测试
132+
@uv run pytest tests/
133+
134+
.PHONY: test-unit
135+
test-unit: ## 运行单元测试
136+
@uv run pytest tests/unittests/
137+
138+
.PHONY: test-e2e
139+
test-e2e: ## 运行端到端测试
140+
@uv run pytest tests/e2e/
141+
142+
.PHONY: coverage
143+
coverage: ## 运行测试并显示覆盖率报告(全量代码 + 增量代码)
144+
@echo "📊 运行覆盖率测试..."
145+
@uv run python scripts/check_coverage.py --incremental --no-check
146+
147+
.PHONY: coverage-full
148+
coverage-full: ## 运行测试并显示全量覆盖率报告
149+
@echo "📊 运行全量覆盖率测试..."
150+
@uv run python scripts/check_coverage.py --no-check
151+
152+
.PHONY: coverage-check
153+
coverage-check: ## 运行测试并检查覆盖率是否达标(根据 coverage.yaml 配置)
154+
@echo "🔍 运行覆盖率检查..."
155+
@uv run python scripts/check_coverage.py --incremental
156+
157+
.PHONY: coverage-check-full
158+
coverage-check-full: ## 运行测试并检查全量覆盖率是否达标
159+
@echo "🔍 运行全量覆盖率检查..."
160+
@uv run python scripts/check_coverage.py
161+
162+
.PHONY: coverage-dir
163+
coverage-dir: ## 检查特定目录的覆盖率 (使用 DIR=agentrun/server)
164+
@if [ -z "$(DIR)" ]; then \
165+
echo "Usage: make coverage-dir DIR=agentrun/server"; \
166+
exit 1; \
167+
fi
168+
@echo "📊 检查目录 $(DIR) 的覆盖率..."
169+
@uv run python scripts/check_coverage.py --source $(DIR) --check-directories $(DIR)
170+
171+
.PHONY: coverage-server
172+
coverage-server: ## 检查 server 模块的覆盖率
173+
@echo "📊 检查 server 模块覆盖率..."
174+
@uv run pytest tests/unittests/server/ --cov=agentrun/server --cov-report=term-missing --cov-branch
175+
176+
.PHONY: coverage-json
177+
coverage-json: ## 输出 JSON 格式的覆盖率报告
178+
@uv run python scripts/check_coverage.py --json-only --no-check
179+
180+
.PHONY: coverage-html
181+
coverage-html: ## 生成 HTML 覆盖率报告
182+
@echo "📊 生成 HTML 覆盖率报告..."
183+
@uv run pytest tests/ --cov=agentrun --cov-report=html --cov-branch
184+
@echo "✅ HTML 报告已生成到 htmlcov/ 目录"

0 commit comments

Comments
 (0)