Tuning Random Generators: Property-Based Testing as Probabilistic Programming

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Tjoa, Ryan, Garg, Poorva, Goldstein, Harrison, Millstein, Todd, Pierce, Benjamin, Broeck, Guy Van den
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866908655573532672
author Tjoa, Ryan
Garg, Poorva
Goldstein, Harrison
Millstein, Todd
Pierce, Benjamin
Broeck, Guy Van den
author_facet Tjoa, Ryan
Garg, Poorva
Goldstein, Harrison
Millstein, Todd
Pierce, Benjamin
Broeck, Guy Van den
contents Property-based testing validates software against an executable specification by evaluating it on randomly generated inputs. The standard way that PBT users generate test inputs is via generators that describe how to sample test inputs through random choices. To achieve a good distribution over test inputs, users must tune their generators, i.e., decide on the weights of these individual random choices. Unfortunately, it is very difficult to understand how to choose individual generator weights in order to achieve a desired distribution, so today this process is tedious and limits the distributions that can be practically achieved. In this paper, we develop techniques for the automatic and offline tuning of generators. Given a generator with undetermined symbolic weights and an objective function, our approach automatically learns values for these weights that optimize for the objective. We describe useful objective functions that allow users to (1) target desired distributions and (2) improve the diversity and validity of their test cases. We have implemented our approach in a novel discrete probabilistic programming system, Loaded Dice, that supports differentiation and parameter learning, and use it as a language for generators. We empirically demonstrate that our approach is effective at optimizing generator distributions according to the specified objective functions. We also perform a thorough evaluation on PBT benchmarks, demonstrating that, when automatically tuned for diversity and validity, the generators exhibit a 3.1-7.4x speedup in bug finding.
format Preprint
id arxiv_https___arxiv_org_abs_2508_14394
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Tuning Random Generators: Property-Based Testing as Probabilistic Programming
Tjoa, Ryan
Garg, Poorva
Goldstein, Harrison
Millstein, Todd
Pierce, Benjamin
Broeck, Guy Van den
Programming Languages
Software Engineering
D.3; D.2.5; G.3
Property-based testing validates software against an executable specification by evaluating it on randomly generated inputs. The standard way that PBT users generate test inputs is via generators that describe how to sample test inputs through random choices. To achieve a good distribution over test inputs, users must tune their generators, i.e., decide on the weights of these individual random choices. Unfortunately, it is very difficult to understand how to choose individual generator weights in order to achieve a desired distribution, so today this process is tedious and limits the distributions that can be practically achieved. In this paper, we develop techniques for the automatic and offline tuning of generators. Given a generator with undetermined symbolic weights and an objective function, our approach automatically learns values for these weights that optimize for the objective. We describe useful objective functions that allow users to (1) target desired distributions and (2) improve the diversity and validity of their test cases. We have implemented our approach in a novel discrete probabilistic programming system, Loaded Dice, that supports differentiation and parameter learning, and use it as a language for generators. We empirically demonstrate that our approach is effective at optimizing generator distributions according to the specified objective functions. We also perform a thorough evaluation on PBT benchmarks, demonstrating that, when automatically tuned for diversity and validity, the generators exhibit a 3.1-7.4x speedup in bug finding.
title Tuning Random Generators: Property-Based Testing as Probabilistic Programming
topic Programming Languages
Software Engineering
D.3; D.2.5; G.3
url https://arxiv.org/abs/2508.14394