← 中文资源

简体中文版本

审批测试

审批测试把实际输出与已评审并提交的基线比较,任何差异都需人工确认后才被接受,适合难以手写预期的复杂输出。

阅读英文原文

概念概述

审批测试(Approval Testing)指的是:审批测试把实际输出与已评审并提交的基线比较,任何差异都需人工确认后才被接受,适合难以手写预期的复杂输出。

从更严格的定义看,Approval testing is a technique in which the test records the current output of a unit and compares it with a stored, human-approved baseline, failing when they differ. 该概念在工程实践中的价值,在于它能帮助团队用统一的语言描述一个具体的质量属性或设计约束,从而在评审与协作中减少歧义。

为什么需要它

It suits complex or opaque outputs such as formatted reports, rendered documents, and legacy code where expected values are hard to state by hand. 它与 Test Parallelization and Sharding、Mock Objects and Behaviour Verification、Golden Master Testing 等概念经常一起出现,用于解决相近的工程问题。理解它的适用场景,有助于在多种备选方案之间做出有依据的取舍,而不是凭直觉选择技术方案。

常见误解

  • approval testing verifies correctness automatically
  • approving a diff means the new output is definitely right

需要避免的反模式

  • bulk-approving a large diff without reading it
  • storing baselines without review in version control

实践要点

  1. The baseline is the specification: the test detects change, while a human decides whether the change is desired, which shifts intent into the review step.
  2. Because diffs are explicit, accidental changes surface, but rubber-stamping approvals erodes the value and quietly blesses regressions.
  3. Baselines must live under version control so a change is reviewable, and they should be updated deliberately rather than regenerated automatically on every run.

参考来源

https://en.wikipedia.org/wiki/Software_testing