quality-metrics

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Quality Metrics

质量指标

Test Coverage Metrics

测试覆盖率指标

Code Coverage Types

覆盖率类型

  • Line Coverage: Percentage of executable lines executed
  • Branch Coverage: Percentage of conditional branches taken
  • Function Coverage: Percentage of functions/methods called
  • Statement Coverage: Percentage of statements executed
  • Condition Coverage: Percentage of boolean sub-conditions evaluated
  • 行覆盖率:已执行的可执行代码行占比
  • 分支覆盖率:已执行的条件分支占比
  • 函数覆盖率:已调用的函数/方法占比
  • 语句覆盖率:已执行的语句占比
  • 条件覆盖率:已评估的布尔子条件占比

Coverage Targets

覆盖率目标

Critical Business Logic: 90-100%
Core Application Code: 80-90%
Utility/Helper Code: 70-80%
Configuration/Setup Code: 50-70%
Critical Business Logic: 90-100%
Core Application Code: 80-90%
Utility/Helper Code: 70-80%
Configuration/Setup Code: 50-70%

Coverage Tools

覆盖率工具

  • JavaScript: Istanbul, nyc, Jest coverage
  • Python: pytest-cov, coverage.py
  • Java: JaCoCo, Cobertura
  • .NET: dotCover, Coverlet
  • Go: go test -cover
  • JavaScript:Istanbul、nyc、Jest coverage
  • Python:pytest-cov、coverage.py
  • Java:JaCoCo、Cobertura
  • .NET:dotCover、Coverlet
  • Go:go test -cover

Coverage Best Practices

覆盖率最佳实践

  • Focus on meaningful coverage, not just percentage
  • Prioritize coverage of critical paths
  • Track coverage trends over time
  • Set coverage gates in CI/CD
  • Review uncovered code regularly
  • 关注有意义的覆盖率,而非单纯的百分比
  • 优先覆盖关键路径
  • 跟踪覆盖率随时间的变化趋势
  • 在CI/CD中设置覆盖率门限
  • 定期审查未覆盖的代码

Code Quality Metrics

代码质量指标

Cyclomatic Complexity

圈复杂度

  • Measures code complexity based on control flow
  • Higher complexity = harder to test and maintain
  • Target: < 10 per function/method
Complexity Levels:
1-10: Simple, low risk
11-20: Moderate complexity, medium risk
21-50: High complexity, high risk
50+: Very high complexity, very high risk
  • 基于控制流衡量代码复杂度
  • 复杂度越高,测试和维护难度越大
  • 目标:每个函数/方法 < 10
复杂度等级:
1-10: 简单,低风险
11-20: 中等复杂度,中风险
21-50: 高复杂度,高风险
50+: 极高复杂度,极高风险

Maintainability Index

可维护性指数

  • Composite metric combining complexity, volume, and structure
  • Scale: 0-100 (higher is better)
  • Target: > 70
Maintainability Levels:
85-100: Highly maintainable
70-84: Moderately maintainable
50-69: Difficult to maintain
0-49: Very difficult to maintain
  • 结合复杂度、代码量和结构的综合指标
  • 范围:0-100(数值越高越好)
  • 目标: > 70
可维护性等级:
85-100: 高度可维护
70-84: 中等可维护
50-69: 难以维护
0-49: 极难维护

Code Duplication

代码重复率

  • Percentage of duplicated code
  • Target: < 5%
  • High duplication indicates need for refactoring
  • 重复代码的占比
  • 目标: < 5%
  • 高重复率表明需要重构

Code Smells

代码坏味道

  • Long Methods: Methods > 50 lines
  • Large Classes: Classes > 500 lines
  • Deep Nesting: Nesting > 4 levels
  • Long Parameter Lists: > 4 parameters
  • Feature Envy: Methods using other objects more than their own
  • 长方法:方法超过50行
  • 大类:类超过500行
  • 深层嵌套:嵌套层级超过4层
  • 长参数列表:参数数量超过4个
  • 特性羡慕:方法使用其他对象的次数多于自身对象

Technical Debt Ratio

技术债务比率

Technical Debt Ratio = Cost to Fix Issues / Cost to Develop New Features
Target: < 5%
技术债务比率 = 修复问题的成本 / 开发新功能的成本
目标: < 5%

Defect Metrics

缺陷指标

Defect Density

缺陷密度

  • Defects per thousand lines of code (KLOC)
  • Defects per function point
  • Defects per module/component
Defect Density = Total Defects / Size Metric (KLOC, FP)
Target: < 1 defect per KLOC
  • 每千行代码(KLOC)的缺陷数
  • 每个功能点(FP)的缺陷数
  • 每个模块/组件的缺陷数
缺陷密度 = 总缺陷数 / 规模指标(KLOC、FP)
目标: < 1个缺陷/千行代码

Defect Removal Efficiency (DRE)

缺陷移除效率(DRE)

  • Percentage of defects found before release
  • Higher is better
DRE = (Defects Found Before Release / Total Defects) × 100
Target: > 90%
  • 发布前发现的缺陷占比
  • 数值越高越好
DRE = (发布前发现的缺陷数 / 总缺陷数) × 100
目标: > 90%

Defect Leakage

缺陷逃逸率

  • Percentage of defects found after release
  • Lower is better
Defect Leakage = (Defects Found After Release / Total Defects) × 100
Target: < 10%
  • 发布后发现的缺陷占比
  • 数值越低越好
缺陷逃逸率 = (发布后发现的缺陷数 / 总缺陷数) × 100
目标: < 10%

Defect Age

缺陷周期

  • Time from defect introduction to detection
  • Time from defect detection to resolution
Defect Age = Detection Date - Introduction Date
Resolution Time = Resolution Date - Detection Date
Target: < 7 days for critical defects
  • 从缺陷引入到被发现的时间
  • 从缺陷被发现到被解决的时间
缺陷周期 = 发现日期 - 引入日期
解决时间 = 解决日期 - 发现日期
目标: 关键缺陷的解决时间 < 7天

Defect Severity Distribution

缺陷严重程度分布

  • Critical: System failure, data loss
  • High: Major functionality broken
  • Medium: Minor functionality broken
  • Low: Cosmetic issues, typos
  • Critical(严重):系统故障、数据丢失
  • High(高):主要功能失效
  • Medium(中):次要功能失效
  • Low(低):界面问题、拼写错误

Defect Trend Analysis

缺陷趋势分析

  • Track defects over time
  • Identify patterns and trends
  • Correlate with code changes
  • Predict future defect rates
  • 跟踪缺陷随时间的变化
  • 识别模式和趋势
  • 与代码变更关联分析
  • 预测未来缺陷率

Quality Gates and Acceptance Criteria

质量门控与验收标准

Quality Gate Examples

质量门控示例

Code Quality Gate:
- Code coverage ≥ 80%
- No critical or high severity defects
- Cyclomatic complexity ≤ 10
- No security vulnerabilities
- All tests passing

Performance Gate:
- p95 response time < 500ms
- Error rate < 0.1%
- Throughput ≥ 1000 RPS
- CPU utilization < 70%

Security Gate:
- No high/critical vulnerabilities
- OWASP Top 10 compliance
- Dependency scan clean
- Authentication/authorization tested
代码质量门控:
- 代码覆盖率 ≥ 80%
- 无严重或高优先级缺陷
- 圈复杂度 ≤ 10
- 无安全漏洞
- 所有测试通过

性能门控:
- p95响应时间 < 500ms
- 错误率 < 0.1%
- 吞吐量 ≥ 1000 RPS
- CPU使用率 < 70%

安全门控:
- 无高/严重级漏洞
- 符合OWASP Top 10标准
- 依赖项扫描无问题
- 身份认证/授权已测试

Acceptance Criteria

验收标准

  • Functional Requirements: All features work as specified
  • Non-Functional Requirements: Performance, security, usability met
  • Test Coverage: Minimum coverage thresholds met
  • Defect Standards: No defects above acceptable severity
  • Documentation: All documentation complete and accurate
  • 功能需求:所有功能按规格正常工作
  • 非功能需求:满足性能、安全、易用性要求
  • 测试覆盖率:达到最低覆盖率阈值
  • 缺陷标准:无超出可接受严重程度的缺陷
  • 文档:所有文档完整且准确

Test Reporting and Dashboards

测试报告与仪表盘

Test Execution Reports

测试执行报告

  • Total tests run
  • Pass/fail counts and percentages
  • Test execution time
  • Flaky test identification
  • Test failure categorization
  • 总测试用例数
  • 通过/失败数量及占比
  • 测试执行时间
  • 不稳定测试识别
  • 测试失败分类

Coverage Reports

覆盖率报告

  • Line, branch, function coverage
  • Coverage by module/component
  • Uncovered code highlighting
  • Coverage trends over time
  • Coverage comparison between branches
  • 行、分支、函数覆盖率
  • 按模块/组件划分的覆盖率
  • 未覆盖代码高亮
  • 覆盖率随时间的变化趋势
  • 分支间覆盖率对比

Defect Reports

缺陷报告

  • Open defects by severity
  • Defect trends and patterns
  • Defect age distribution
  • Defect resolution time
  • Defect density by module
  • 按严重程度划分的未解决缺陷
  • 缺陷趋势和模式
  • 缺陷周期分布
  • 缺陷解决时间
  • 按模块划分的缺陷密度

Performance Reports

性能报告

  • Response time metrics (p50, p95, p99)
  • Throughput metrics
  • Error rates
  • Resource utilization
  • Performance trends over time
  • 响应时间指标(p50、p95、p99)
  • 吞吐量指标
  • 错误率
  • 资源使用率
  • 性能随时间的变化趋势

Dashboard Elements

仪表盘元素

  • Overall quality score
  • Test coverage gauge
  • Defect trend chart
  • Performance metrics
  • Build health status
  • Quality gate status
  • 整体质量得分
  • 测试覆盖率仪表盘
  • 缺陷趋势图表
  • 性能指标
  • 构建健康状态
  • 质量门控状态

QA KPIs and Metrics Tracking

QA关键绩效指标与指标跟踪

Process Metrics

流程指标

  • Test Execution Time: Time to run test suite
  • Test Automation Rate: Percentage of tests automated
  • Test Case Count: Total number of test cases
  • Test Case Execution: Number of tests executed per period
  • Defect Detection Rate: Defects found per testing hour
  • 测试执行时间:运行测试套件的时间
  • 测试自动化率:自动化测试的占比
  • 测试用例数:总测试用例数量
  • 测试用例执行量:每周期执行的测试用例数
  • 缺陷发现率:每测试小时发现的缺陷数

Product Metrics

产品指标

  • Defect Escape Rate: Defects found in production
  • Mean Time to Detection: Time to find defects
  • Mean Time to Resolution: Time to fix defects
  • Customer Reported Defects: Defects reported by users
  • Test Coverage: Code, feature, and requirement coverage
  • 缺陷逃逸率:生产环境中发现的缺陷
  • 平均发现时间:发现缺陷的时间
  • 平均解决时间:修复缺陷的时间
  • 用户反馈缺陷:用户报告的缺陷
  • 测试覆盖率:代码、功能及需求覆盖率

Team Metrics

团队指标

  • Test Case Productivity: Test cases created per person-hour
  • Automation Productivity: Automated tests created per person-hour
  • Defect Detection Efficiency: Defects found per person-hour
  • Test Execution Efficiency: Tests executed per person-hour
  • 测试用例生产力:每人每小时创建的测试用例数
  • 自动化生产力:每人每小时创建的自动化测试用例数
  • 缺陷发现效率:每人每小时发现的缺陷数
  • 测试执行效率:每人每小时执行的测试用例数

Quality Metrics

质量指标

  • Overall Quality Score: Composite quality metric
  • Test Pass Rate: Percentage of passing tests
  • Defect Density: Defects per size metric
  • Code Quality Score: Based on complexity, duplication, smells
  • Performance Score: Based on response time, throughput, errors
  • 整体质量得分:综合质量指标
  • 测试通过率:通过测试的占比
  • 缺陷密度:每规模单位的缺陷数
  • 代码质量得分:基于复杂度、重复率、代码坏味道
  • 性能得分:基于响应时间、吞吐量、错误率

Metrics Dashboard

指标仪表盘

Quality Dashboard:
┌─────────────────────────────────────────┐
│ Overall Quality Score: 87/100          │
├─────────────────────────────────────────┤
│ Test Coverage: 85%                      │
│ ├─ Line: 87%                            │
│ ├─ Branch: 82%                          │
│ └─ Function: 90%                       │
├─────────────────────────────────────────┤
│ Code Quality: 82/100                    │
│ ├─ Complexity: 8.2 avg                  │
│ ├─ Duplication: 3.1%                    │
│ └─ Maintainability: 78                  │
├─────────────────────────────────────────┤
│ Defects: 12 open                        │
│ ├─ Critical: 1                          │
│ ├─ High: 3                              │
│ ├─ Medium: 5                            │
│ └─ Low: 3                               │
├─────────────────────────────────────────┤
│ Performance: 92/100                     │
│ ├─ p95 Response: 420ms                  │
│ ├─ Throughput: 1250 RPS                 │
│ └─ Error Rate: 0.05%                    │
└─────────────────────────────────────────┘
质量仪表盘:
┌─────────────────────────────────────────┐
│ 整体质量得分: 87/100                    │
├─────────────────────────────────────────┤
│ 测试覆盖率: 85%                        │
│ ├─ 行覆盖率: 87%                        │
│ ├─ 分支覆盖率: 82%                      │
│ └─ 函数覆盖率: 90%                       │
├─────────────────────────────────────────┤
│ 代码质量: 82/100                        │
│ ├─ 圈复杂度: 平均8.2                    │
│ ├─ 代码重复率: 3.1%                      │
│ └─ 可维护性: 78                        │
├─────────────────────────────────────────┤
│ 未解决缺陷: 12个                        │
│ ├─ 严重: 1个                            │
│ ├─ 高: 3个                              │
│ ├─ 中: 5个                              │
│ └─ 低: 3个                               │
├─────────────────────────────────────────┤
│ 性能: 92/100                           │
│ ├─ p95响应时间: 420ms                  │
│ ├─ 吞吐量: 1250 RPS                     │
│ └─ 错误率: 0.05%                        │
└─────────────────────────────────────────┘

Metrics Collection and Analysis

指标收集与分析

Data Collection

数据收集

  • Automated collection from CI/CD pipelines
  • Integration with test frameworks
  • Real-time monitoring and alerts
  • Historical data storage
  • Data normalization and aggregation
  • 从CI/CD流水线自动收集
  • 与测试框架集成
  • 实时监控与告警
  • 历史数据存储
  • 数据标准化与聚合

Analysis Techniques

分析技术

  • Trend analysis over time
  • Comparison between branches/releases
  • Correlation with code changes
  • Root cause analysis of quality issues
  • Predictive analytics for quality forecasting
  • 随时间的趋势分析
  • 分支/版本间的对比分析
  • 与代码变更的关联分析
  • 质量问题的根本原因分析
  • 质量预测的预测分析

Reporting Frequency

报告频率

  • Real-time: Build status, test failures, critical defects
  • Daily: Test execution, defect updates, performance metrics
  • Weekly: Quality trends, coverage reports, team metrics
  • Monthly: Quality scorecards, process improvements, strategic insights
  • Quarterly: Quality reviews, goal setting, process optimization
  • 实时:构建状态、测试失败、严重缺陷
  • 每日:测试执行、缺陷更新、性能指标
  • 每周:质量趋势、覆盖率报告、团队指标
  • 每月:质量评分卡、流程改进、战略洞察
  • 每季度:质量评审、目标设定、流程优化

Continuous Improvement

持续改进

  • Identify quality trends and patterns
  • Set quality goals and targets
  • Track progress toward goals
  • Implement process improvements based on metrics
  • Celebrate quality achievements
  • 识别质量趋势和模式
  • 设定质量目标和阈值
  • 跟踪目标进度
  • 基于指标实施流程改进
  • 庆祝质量成果