Basis path testing is a cornerstone of structural testing, yet traditional automated methods, relying on greedy graph-traversal algorithms (e.g., DFS/BFS), often generate sub-optimal paths. This structural inferiority is not a trivial issue; it directly impedes downstream testing activities by complicating automated test data generation and increasing the cognitive load for human engineers. This paper reframes basis path generation from a procedural search task into a declarative optimization problem. We introduce a Mixed Integer Programming (MIP) framework designed to produce a complete basis path set that is globally optimal in its structural simplicity. Our framework includes two complementary strategies: a Holistic MIP model that guarantees a theoretically optimal path set, and a scalable Incremental MIP strategy for large, complex topologies. The incremental approach features a multi-objective function that prioritizes path simplicity and incorporates a novelty penalty to maximize the successful generation of linearly independent paths. Empirical evaluations on both real-code and large-scale synthetic Control Flow Graphs demonstrate that our Incremental MIP strategy achieves a 100\% success rate in generating complete basis sets, while remaining computationally efficient. Our work provides a foundational method for generating a high-quality structural "scaffold" that can enhance the efficiency and effectiveness of subsequent test generation efforts.
翻译:基路径测试是结构测试的基石,然而传统的自动化方法依赖贪心图遍历算法(如DFS/BFS),往往生成次优路径。这种结构缺陷并非无关紧要的问题;它通过使自动化测试数据生成复杂化并增加人工工程师的认知负荷,直接阻碍了下游测试活动。本文将基路径生成从过程式搜索任务重新定义为声明式优化问题。我们引入了一个混合整数规划(MIP)框架,旨在生成一个在结构简洁性上全局最优的完整基路径集。我们的框架包含两种互补策略:保证理论最优路径集的整体MIP模型,以及适用于大型复杂拓扑的可扩展增量MIP策略。该增量方法采用多目标函数,优先考虑路径简洁性,并引入新颖性惩罚以最大化线性无关路径的成功生成。在真实代码和大规模合成控制流图上的实证评估表明,我们的增量MIP策略在生成完整基集方面实现了100%的成功率,同时保持了计算效率。我们的工作为生成高质量的结构“支架”提供了基础方法,可提升后续测试生成工作的效率与效果。