一句话:结合语法模糊测试、动态不变式检测与变异分析,自动推断 Java 类的断言式规约。
在面向对象设计中,类规约用于表达方法预期行为与对象约束,对测试生成、缺陷发现和自动调试都很有价值,但开发者很少主动编写。本文以工具演示形式提出 SpecFuzzer:给定待分析的 Java 类,它首先从类中自动提取语法,并据此生成候选断言;随后借助动态不变式检测器 Daikon,利用现有测试套件过滤掉被反例证伪的断言;最后通过基于变异分析的机制对剩余断言进行聚类与排序,将相似约束归为一组并优先保留更强的断言。工具已在 GitHub 开源,并提供演示视频。
In object-oriented design, class specifications are primarily used to express properties describing the intended behavior of the class methods and constraints on class' objects. Although the presence of these specifications is important for various software engineering tasks such as test generation, bug finding and automated debugging, developers rarely write them. In this tool demo we present the details of SPEcFuzZER, a tool that aims at alleviating the problem of writing class specifications by using a combination of grammar-based fuzzing, dynamic invariant detection and mutation analysis to auto-maticallyautomatically infer specifications for Java classes. Given a class under analysis, SPEcFuzZER uses (i) a generator of candidate assertions derived from a grammar automatically extracted from the class; (ii) a dynamic invariant detector -Daikon- in order to discard the assertions invalidated by a test suite; and (iii) a mutation-based mechanism to cluster and rank assertions, so that similar constraints are grouped together and the stronger assertions are prioritized. The tool is available on GitHub at https://github.com/facumolina/specfuzzer, and the demo video can be found on YouTube: https://youtu.be/IfakNCbzOUg.