- 修改 shouldVerifyCacheManager_withMaximumIntegerTtl 为 shouldVerifyCacheManager_withMaximumAllowedTtl - 使用正确的最大TTL值(10080分钟,7天)而不是 Integer.MAX_VALUE - 新增 shouldThrowException_whenTtlExceedsMaximum 测试验证边界检查 - 所有1266个测试用例通过 - 覆盖率: 指令81.89%, 行88.48%, 分支51.55% docs: 添加项目状态报告 - 生成 PROJECT_STATUS_REPORT.md 详细记录项目当前状态 - 包含质量指标、已完成功能、待办事项和技术债务
152 lines
3.3 KiB
YAML
152 lines
3.3 KiB
YAML
# AI生成测试质量门禁配置
|
|
# 基于1210个测试的真实经验
|
|
|
|
---
|
|
|
|
gates:
|
|
# 门禁1: 虚假测试检测
|
|
fake_test_detection:
|
|
enabled: true
|
|
block_on_issue: true
|
|
|
|
checks:
|
|
- name: "no_framework_testing"
|
|
description: "禁止测试getter/setter/构造函数"
|
|
banned_patterns:
|
|
- "should.*whenGet[A-Z].*"
|
|
- "should.*whenSet[A-Z].*"
|
|
- "shouldConstruct.*"
|
|
max_violations: 0
|
|
|
|
- name: "no_fake_assertions"
|
|
description: "禁止虚假断言"
|
|
banned_assertions:
|
|
- "assertTrue(true)"
|
|
- "assertFalse(false)"
|
|
- "assertNotNull(new Object())"
|
|
- "assertEquals(1, 1)"
|
|
max_violations: 0
|
|
|
|
- name: "meaningful_assertions"
|
|
description: "必须有业务意义断言"
|
|
min_assertions: 2
|
|
min_business_verification: 1
|
|
max_null_checks_ratio: 0.5
|
|
|
|
# 门禁2: 边界条件检查
|
|
boundary_coverage:
|
|
enabled: true
|
|
warning_only: false
|
|
|
|
requirements:
|
|
- type: "numeric"
|
|
min_test_values: 5
|
|
required_values: ["MIN", "-1", "0", "1", "MAX"]
|
|
|
|
- type: "string"
|
|
min_test_values: 6
|
|
required_values: ["null", "empty", "single", "max_length", "unicode", "special"]
|
|
|
|
- type: "collection"
|
|
min_test_values: 4
|
|
required_values: ["null", "empty", "single", "max_size"]
|
|
|
|
- type: "concurrency"
|
|
min_tests: 1
|
|
required: false
|
|
|
|
# 门禁3: Mock使用检查
|
|
mock_usage:
|
|
enabled: true
|
|
max_mock_ratio: 0.5
|
|
|
|
banned_layers:
|
|
- "com.mosquito.project.service.*"
|
|
- "com.mosquito.project.controller.*"
|
|
- "com.mosquito.project.repository.*"
|
|
|
|
required_real:
|
|
- interface: "javax.sql.DataSource"
|
|
implementation: "testcontainers"
|
|
- interface: "org.springframework.data.redis.connection.RedisConnectionFactory"
|
|
implementation: "testcontainers"
|
|
|
|
# 门禁4: 分支覆盖率
|
|
branch_coverage:
|
|
enabled: true
|
|
min_coverage: 60
|
|
auto_generate: true
|
|
|
|
# 门禁5: 可维护性
|
|
maintainability:
|
|
enabled: true
|
|
|
|
naming:
|
|
pattern: "should_.*_when_.*"
|
|
required_format: "BDD"
|
|
|
|
structure:
|
|
require_given_when_then: true
|
|
max_lines_per_test: 30
|
|
max_duplicate_code_ratio: 0.1
|
|
|
|
assertions:
|
|
prefer_assertj: true
|
|
ban_junit4: true
|
|
|
|
# 门禁6: 性能基础
|
|
performance_baseline:
|
|
enabled: true
|
|
warning_only: true
|
|
|
|
requirements:
|
|
- type: "execution_time"
|
|
max_ms: 100
|
|
|
|
- type: "large_object"
|
|
min_size_mb: 1
|
|
test_required: false
|
|
|
|
- type: "concurrent_load"
|
|
min_threads: 2
|
|
test_required: false
|
|
|
|
scoring:
|
|
weights:
|
|
fake_test_detection: 25
|
|
boundary_coverage: 20
|
|
mock_usage: 20
|
|
branch_coverage: 20
|
|
maintainability: 10
|
|
performance_baseline: 5
|
|
|
|
total_thresholds:
|
|
A: 90
|
|
B: 80
|
|
C: 70
|
|
D: 60
|
|
F: 0
|
|
|
|
actions:
|
|
on_failure:
|
|
generate_report: true
|
|
suggest_fixes: true
|
|
block_merge: true
|
|
|
|
on_warning:
|
|
generate_report: true
|
|
allow_merge: true
|
|
|
|
reporting:
|
|
format: "html"
|
|
output_path: "target/quality-gates-report.html"
|
|
include_suggestions: true
|
|
include_examples: true
|
|
|
|
sections:
|
|
- summary
|
|
- gate_results
|
|
- violations
|
|
- suggestions
|
|
- examples
|