Test input generators are an important part of property-based testing (PBT) frameworks. Because PBT is intended to test deep semantic and structural properties of a program, the outputs produced by these generators can be complex data structures, constrained to satisfy properties the developer believes is most relevant to testing the function of interest. An important feature expected of these generators is that they be capable of producing all acceptable elements that satisfy the function's input type and generator-provided constraints. However, it is not readily apparent how we might validate whether a particular generator's output satisfies this coverage requirement. Typically, developers must rely on manual inspection and post-mortem analysis of test runs to determine if the generator is providing sufficient coverage; these approaches are error-prone and difficult to scale as generators become more complex. To address this important concern, we present a new refinement type-based verification procedure for validating the coverage provided by input test generators, based on a novel interpretation of types that embeds ``must-style'' underapproximate reasoning principles as a fundamental part of the type system. The types associated with expressions now capture the set of values guaranteed to be produced by the expression, rather than the typical formulation that uses types to represent the set of values an expression may produce. Beyond formalizing the notion of coverage types in the context of a rich core language with higher-order procedures and inductive datatypes, we also present a detailed evaluation study to justify the utility of our ideas.
翻译:测试输入生成器是属性测试(PBT)框架的重要组成部分。由于PBT旨在测试程序的深层次语义和结构属性,生成器产生的输出可以是复杂的数据结构,限制为满足开发人员认为最相关的属性。这些生成器的重要特征之一是,它们能够生成满足函数输入类型和生成器提供的约束的所有可接受元素。然而,我们很难验证某个特定生成器的输出是否满足此覆盖要求。通常,开发人员必须依赖手动检查和事后分析测试运行结果来确定生成器是否提供足够的覆盖范围;这些方法容易出错,并且随着生成器变得更加复杂,很难扩展。为了解决这个重要问题,我们提出了一种基于精化类型的验证过程,用于验证输入测试生成器提供的覆盖范围,基于类型系统中嵌入“must-style”欠拟合推理原则的新解释。现在,与表达式相关的类型捕获保证由表达式产生的值集,而不是使用类型来表示表达式可能产生的值集的典型公式化。除了在具有高阶过程和归纳数据类型的丰富核心语言上形式化覆盖类型的概念之外,我们还进行了详细的评估研究,以证明我们的想法的实用性。