Property-based testing (PBT) is a popular technique for establishing confidence in software, where users write properties -- i.e., executable specifications -- that can be checked many times in a loop by a testing framework. In modern PBT frameworks, properties are usually written in shallowly embedded domain-specific languages, and their definition is tightly coupled to the way they are tested. Such frameworks often provide convenient configuration options to customize aspects of the testing process, but users are limited to precisely what library authors had the prescience to allow for when developing the framework; if they want more flexibility, they may need to write a new framework from scratch. We propose a new, deeper language for properties based on a mixed embedding that we call deferred binding abstract syntax, which reifies properties as a data structure and decouples them from the property runners that execute them. We implement this language in Rocq and Racket, leveraging the power of dependent and dynamic types, respectively. Finally, we showcase the flexibility of this new approach by rapidly prototyping a variety of property runners, highlighting domain-specific testing improvements that can be unlocked by more programmable testing.
翻译:属性基测试(PBT)是一种流行的软件置信度建立技术,用户通过编写属性(即可执行规约),由测试框架在循环中多次检查这些属性。在现代PBT框架中,属性通常采用浅层嵌入领域特定语言编写,其定义与测试方式紧密耦合。这类框架虽常提供便捷配置选项以定制测试流程,但用户仅能选择框架开发者预见的有限可能性;若需更高灵活性,则需从头编写新框架。我们提出一种基于混合嵌入的更深层属性语言——延迟绑定抽象语法,该语言将属性具体化为数据结构,并使其与执行属性的运行器解耦。我们分别在Rocq和Racket中实现该语言,充分利用依赖类型与动态类型的优势。最后,通过快速原型化多种属性运行器,我们展示了新方法的灵活性,并突出其如何解锁面向特定领域的测试改进潜能。