Skip to content
Preprint

DSpec2Test: Specification-Driven Test Generation in Dafny

Aug 2026 · 0 citations · 18 references
Computer Science

TL;DR

DSpec2Test is presented, a specification-driven test generation tool for Dafny that automatically derives tests from formal specifications, without considering implementation details, and achieves a 93.9% mutation kill rate on a dataset of 131 mutants, outperforming Block's 82.4%, and uniquely killing 17 mutants.

Abstract

Verification-aware languages, such as Dafny, integrate logical constructs into code and enable automatic verification of program correctness. However, tests remain helpful in scenarios that verification alone does not address (e.g., to support test-driven development). Existing Dafny test generation tools are implementation-based, limiting their applicability in this context. We present DSpec2Test, a specification-driven test generation tool for Dafny that automatically derives tests from formal specifications, without considering implementation details. Our tool extends Dafny's generate-tests command with a new blackbox mode based on Disjunctive Normal Form (DNF) equivalence class partitioning and optional Boundary Value Analysis (BVA). DSpec2Test relies on the Z3 SMT solver to synthesize inputs and expected outputs that meet the specification-derived constraints. We evaluate DSpec2Test on programs from DafnyBench mutated using MutDafny and compare it against Dafny's existing implementation-driven Block mode. DSpec2Test achieves a 93.9% mutation kill rate on a dataset of 131 mutants, outperforming Block's 82.4%, and uniquely killing 17 mutants. These results suggest that specification-driven testing is an effective and complementary approach for testing Dafny programs.

View source

Similar papers

#machine learning Review Sep 2026

Robustness of LLM-Generated SystemVerilog Assertions to Semantics-Preserving RTL Transformations

Large language models (LLMs) are increasingly being explored for automating SystemVerilog Assertion (SVA) generation, yet most evaluations report correctness on a single syntactic representation of an input. Such point accuracy does not reveal whether a model's correct output is stable when the same RTL behavior is wri...

Fnu Aditi · 1 citation
Open access Sep 2026

From Formal Specifications to Simulations: Generating Executable Hardware Models for Early Validation

Formal specification techniques have been introduced to address the ambiguities inherent in natural-language hardware specifications. One such approach is the Universal Specification Format (USF), which provides a machine-readable, formal reference for Register-Transfer Level (RTL) verification. However, verifying agai...

Robert Kunzelmann, Raphael Kunz, Stephanie Ecker et al. · 0 citations
Preprint Sep 2026

LLM-enabled Behavior Driven Development Workflow for Formally Verified Hardware Designs

Recently, the use of Large Language Models (LLMs) for different tasks in the Electronic Design Automation (EDA) life-cycle has been studied extensively, but an integrated view is lacking. Specifications are the foundation of this life-cycle, but they suffer from ambiguity when written in natural language, which especia...

Luca Müller, Qian Liu, Rolf Drechsler · 0 citations
#artificial intelligence Preprint Sep 2026

Self-Spec Verifiable Code Generation

Large language models (LLMs) may generate unreliable code on corner cases missed by testing, while formal verification can provide machine-checkable guarantees. Recently, researchers have proposed several benchmarks to evaluate the capabilities of LLMs in generating formally verifiable code, where LLMs need to formulat...

Jia-Ru Qian, Yihong Dong, Yong-Ming Li et al. · 0 citations
#small language model Preprint Sep 2026

Path2Spec: Path-Aware Specification Generation via Large Language Models

This work introduces Path2Spec, a divide-and-conquer framework that leverages LLMs to extract all execution paths from an input program, generates path-specific specifications for each, and merges them into a comprehensive overall specification.

Dan Huang, Zhensu Sun, Hui-Hui Huang et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.