# 组合测试

组合测试是一种软件测试方法，它选取一小组测试配置，覆盖 t 个输入参数的每一种交互，从而无需对所有配置进行穷举测试，就能发现由参数值组合触发的故障。测试者不必枚举每一种可能的输入，而是构建一个覆盖阵列：一张表，每一行是一个测试，每一列是一个参数，其排列方式使得每一种 t 维取值组合至少出现一次。由于实证研究表明大多数软件故障只涉及少数几个交互因素，因此对于较小的 t（通常为 2 到 6），覆盖所有 t 维组合即可检测出大多数故障，而测试集比穷举测试小 \( 20 \cdot X \) 到 \( 700 \cdot X \) 倍。<sup>[1](https://arxiv.org/pdf/2410.19522)</sup>

| 关键事实 | 数值 |
|---|---|
| 方法的输出 | 一个覆盖阵列 CA(N; t, k, v)：在 k 个参数（每个参数有 v 个取值）上的 N 个测试，覆盖所有 t 维组合<sup>[2](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=913948)</sup> |
| 压缩示例 | 1,000 个布尔变量有 1,329,336,000 个三维组合；ACTS 用 71 个测试即可覆盖它们<sup>[3](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)</sup> |
| 故障检测目标 | 在多项研究中，4 维到 6 维覆盖检测出了穷举测试所发现的全部故障<sup>[3](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)</sup> |
| 规模扩展 | 测试数量大致按 \( v^{t} \cdot \log n \) 增长；NIST 已为超过 2,000 个参数生成了测试集<sup>[3](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)</sup> |
| 交互规则 | 观察到的缺陷中，29% 到 68% 涉及一个因素，70% 到 97% 涉及一个或两个因素，没有缺陷涉及超过六个因素<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> |
| 与随机测试的比较 | 要达到 100% 覆盖，随机测试集需要 2 到近 5 倍的测试数量（t = 2、3、4 时的平均比率为 3.9、3.8、3.2）<sup>[5](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf)</sup> |
| 主要工具 | ACTS，一款由 NIST 免费分发的研究工具，已被超过 1200 家公司和组织下载<sup>[6](https://www.nist.gov/publications/acts-combinatorial-test-generation-tool)</sup> |

## 工作原理

[覆盖阵列](https://www.edgepedia.org/zh/covering-array)记作 \( CA_{\lambda}(N; t, k, v) \)，是一个 N × k 的阵列，其中每个 N × t 子阵列都至少包含每个 t 元组 λ 次；软件测试几乎总是取 λ = 1，每一行是一个测试，每一列是一个参数。<sup>[2](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=913948)</sup> 所需的最小行数 N 称为覆盖阵列数，CAN(t, k, v)。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> 除了 t = 2 且 v = 2 的情形——克莱特曼和斯宾塞在 1973 年关于 k 无关集族的研究中给出了最优构造——最优规模通常是未知的。<sup>[7](https://doi.org/10.1016/0012-365x%2873%2990098-8)</sup><sup> • </sup><sup>[8](https://math.nist.gov/coveringarrays/coveringarray.html)</sup>

小 t 值的依据是交互规则：大多数故障由单因素故障或两个因素的联合效应引起，由三个或更多因素之间的交互引起的故障则逐渐减少。<sup>[5](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf)</sup> NIST 对十五年医疗器械召回数据以及浏览器、服务器和数据库系统的故障报告进行了分析，发现 29% 到 68% 的缺陷涉及单个因素，70% 到 97% 涉及一个或两个因素，89% 到 99% 涉及一到三个因素，96% 到 100% 涉及一到四个因素；没有缺陷涉及超过六个因素。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> 与此一致的是，66% 的医疗器械故障由单个变量值触发，97% 由一个或两个变量触发，六项研究中的最大交互水平为 4 到 6。<sup>[2](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=913948)</sup>

覆盖阵列放宽了正交阵列关于每种组合恰好出现 λ 次的要求，允许重复，从而能够处理大得多的问题；软件可以为大量变量生成强度高达 t = 6 的覆盖阵列。<sup>[2](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=913948)</sup>

## 如何实施

实践者首先将系统建模为参数和取值，运用等价类划分和边界值分析；NIST 建议将每个参数的取值数量控制在大约 10 个以下，而数百个参数也不成问题。<sup>[3](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)</sup> 接下来，测试者选择强度 t。一份实践者资料建议默认采用二维覆盖，并根据测试关注点添加三值组合，因为证据表明 2 或 3 个交互通常就足够了；<sup>[1](https://arxiv.org/pdf/2410.19522)</sup> 相比之下，NIST 的材料指出成对测试虽然有用但通常不够充分，而 4 维到 6 维覆盖检测出了穷举测试所发现的全部故障。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> 因此，已发表的建议之间在默认 t 值的选择上存在差异。

然后，测试者使用 ACTS 等工具生成覆盖阵列，并提供排除禁止取值组合的任何约束。<sup>[6](https://www.nist.gov/publications/acts-combinatorial-test-generation-tool)</sup> 在覆盖阵列不切实际的情况下，任何具有 n 个参数的测试集仍然覆盖一定比例的 t 维组合（直至 \( t \leq n \)），这可以由 CCM（组合覆盖度量）工具来测量。<sup>[9](https://nvlpubs.nist.gov/nistpubs/ir/2012/NIST.IR.7878.pdf)</sup>

## 起源

组合测试始于 20 世纪 80 年代，最初是日本[富士通](https://www.edgepedia.org/zh/fujitsu)以及美国 AT&T 贝尔系统衍生机构中使用正交阵列的成对（二维）测试。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> OATS（正交阵列测试系统）用于强度为 2 的正交阵列测试套件，曾用于测试 AT&T 的 PMX/Starmail 系统；后来的 CATS（约束阵列测试系统）排除了禁止组合，是约束覆盖阵列的前身。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> AETG 可用于生成基于覆盖阵列的成对测试套件，IPO 则被开发用于生成排除禁止组合的成对测试套件；切尔翁卡维护的一个网站列出了 37 种工具，从 OATS、CATS、AETG 和 IPO 开始。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup> 从正交阵列转向覆盖阵列反映了一个实际限制：正交阵列无法支持测试设置之间的约束。<sup>[4](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)</sup>

## 变体

ACTS（高级组合测试系统）支持 t 维测试生成，具有混合强度生成和约束处理等高级功能，并提供图形用户界面、命令行界面和应用程序编程接口。<sup>[6](https://www.nist.gov/publications/acts-combinatorial-test-generation-tool)</sup> 其 IPOG 算法可为任意组合测试结构和任意强度 t 生成 t 维套件，并支持约束。<sup>[10](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=918448)</sup>

套件规模随 t 快速增长。对于测试结构 \( 3^{34} \cdot 4^{5} \cdot 2 \)，t = 2、3、4、5、6 的 ACTS/IPOG 套件分别需要 29、137、625、2532 和 9168 个测试用例。<sup>[10](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=918448)</sup> 文献中提到的常见启发式算法族包括 IPO、AETG、正交阵列、PICT 和 DDA，以及 MaxSAT 和元启发式方法。<sup>[11](https://arxiv.org/html/2607.17083)</sup>

新的生成器针对约束成对情形。DivSampCA 由陈凯辰（Kaichen Chen）及其同事于 2026 年在《ACM 软件工程学报》上报告，采用面向元组的自适应采样与全覆盖策略；在 121 个可配置系统实例上，它在 71% 的实例中产生了最小的覆盖阵列（平均小 15.54%），并在 65% 的实例中速度最快（平均时间减少 42.36%）。<sup>[12](https://doi.org/10.1145/3808176)</sup> 一项 2025 年对 2003 年至 2025 年间发表的 91 项原始研究的系统综述将构造策略分为五类：标准、混合、自适应、混合式和[超启发式](https://www.edgepedia.org/zh/hyper-heuristic)。<sup>[13](https://vfast.org/journals/index.php/VTSE/article/view/2125)</sup> 高强度下的[可扩展性](https://www.edgepedia.org/zh/scalability)仍然是一个开放问题：由于严重的可扩展性问题，为高度可配置系统生成 \( t \geq 5 \) 的 t 维覆盖阵列仍然是一项技术挑战。<sup>[14](https://dl.acm.org/doi/10.1145/3744916.3764548)</sup>

## 应用

ACTS 的主要行业应用是数据库和电子商务、航空航天、金融、电信、工业控制和视频游戏软件，用户包括 Adobe、Avaya、戴姆勒股份公司、IBM、捷豹路虎、洛克希德·马丁、红帽、罗克韦尔柯林斯、西门子、美国空军和美国海军陆战队。<sup>[3](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)</sup> 除了软件配置测试之外，组合交互测试还被应用于电路验证、内存纠错、基因调控、材料开发、飞机开发和机器学习验证。<sup>[11](https://arxiv.org/html/2607.17083)</sup> 在编译器测试中，CombCT 将组合测试应用于优化标志的组合。<sup>[14](https://dl.acm.org/doi/10.1145/3744916.3764548)</sup>

## 局限与替代方案

约束是主要的结构性困难：成对约束的存在使得约束覆盖阵列问题成为 NP 难问题，而阻止特定配置的约束通常以临时方式处理。<sup>[11](https://arxiv.org/html/2607.17083)</sup> 故障检测还取决于输入模型；给定输入模型，ACTS 或 IPOG-D 实现等工具会生成满足所选覆盖准则的覆盖阵列，故障检测可以通过变异得分来估计。<sup>[15](https://link.springer.com/article/10.1007/s42979-024-03134-3)</sup> t 维组合的覆盖仅保证检测涉及 t 个或更少因素的故障；涉及更多因素的故障不保证被捕获，尽管 NIST 报告称尚未见到涉及超过六个因素的故障。<sup>[3](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)</sup>

相对于随机测试，覆盖阵列在 100% 组合覆盖方面更高效：随机测试集与组合测试集规模之比在大多数情况下超过 3，t = 2、3、4 时的平均比率分别为 3.9、3.8、3.2。<sup>[5](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf)</sup> 这一优势与每个变量的取值数量成正比，与 t 成反比：对于二元变量，当变量数为 15 个或更多时，随机测试达到了覆盖阵列覆盖率的 96% 到 99%，因此对于以二元变量为主的系统，随机测试可能更具优势。<sup>[5](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf)</sup>

## References

1. [Combinatorial Test Design practice paper (arXiv, 2024)](https://arxiv.org/pdf/2410.19522)
2. [Introduction to Combinatorial Testing (book preprint, Kuhn, Kacker, Lei)](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=913948)
3. [Combinatorial Methods for Trust and Assurance, FAQs](https://csrc.nist.gov/Projects/automated-combinatorial-testing-for-software/faqs)
4. [Factorial Experiments, Covering Arrays, and Combinatorial Testing](https://csrc.nist.gov/CSRC/media/Projects/automated-combinatorial-testing-for-software/documents/MCSFactorialCACT20210521.pdf)
5. [NIST Special Publication 800-142, Practical Combinatorial Testing](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf)
6. [ACTS: A Combinatorial Test Generation Tool (NIST publication page)](https://www.nist.gov/publications/acts-combinatorial-test-generation-tool)
7. [Families of k-independent sets (Discrete Mathematics, 1973)](https://doi.org/10.1016/0012-365x%2873%2990098-8)
8. [NIST Covering Array Tables - What is a covering array?](https://math.nist.gov/coveringarrays/coveringarray.html)
9. [Combinatorial Coverage Measurement (NIST IR 7878)](https://nvlpubs.nist.gov/nistpubs/ir/2012/NIST.IR.7878.pdf)
10. [NIST publication on higher-strength combinatorial test generation (ACTS/IPOG benchmarks)](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=918448)
11. [Optimal Combinatorial Testing with Constraints: The Balancing Act](https://arxiv.org/html/2607.17083)
12. [Kaichen Chen and colleagues (2026). A Tuple-Oriented Sampling Method for Generating Small Pairwise Covering Arrays in Configurable Software Systems. Proceedings of the ACM on software engineering..](https://doi.org/10.1145/3808176)
13. [Systematic Analysis of Search-Based Strategies for Combinatorial Test Suite Construction](https://vfast.org/journals/index.php/VTSE/article/view/2125)
14. [CombCT: Compiler Testing via Combinatorial Testing (ICSE 2026)](https://dl.acm.org/doi/10.1145/3744916.3764548)
15. [On the Impact of Input Models on the Fault Detection Capabilities of Combinatorial Testing](https://link.springer.com/article/10.1007/s42979-024-03134-3)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Software engineering and development process › Software testing and quality

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/combinatorial-testing

English original: https://www.edgepedia.org/combinatorial-testing
