Property
Rasuvaeff\PropertyTesting\Property
Class — Package: property-testing-testo — Source — Version: v0.1.0
Implements: Testo\Pipeline\Attribute\Interceptable
Marks a test method as a property: the PropertyInterceptor takes over, generating random arguments from a generators method until the property has completed $runs successful checks or exhausted its discard budget.
Attribute arguments in PHP must be constant expressions, so the generators cannot be passed inline. Instead name a method (on the same test case) that returns array<string, ArbitraryInterface>, keyed by parameter name. When $generators is null the runner falls back to a method named <testMethod>Generators.
Constructor
php
__construct(
int $runs = 100,
?int $seed = NULL,
?string $generators = NULL,
?int $maxShrinks = NULL,
?string $examples = NULL,
?int $maxDiscards = NULL,
?int $timeoutMs = NULL,
?int $budgetMs = NULL,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$runs | int | 100 | Number of successful random inputs to check. Discarded inputs do not count. |
$seed | ?int | NULL | Fixed seed for reproducibility. Omit to let the runner pick a random one (the failing seed is reported by PropertyViolationException). |
$generators | ?string | NULL | Method name returning array<string, ArbitraryInterface>. Defaults to <testMethod>Generators. |
$maxShrinks | ?int | NULL | Cap on the number of accepted shrink steps. Null (default) means no cap. 0 disables shrinking, reporting the original counterexample unchanged. |
$examples | ?string | NULL | Method name returning iterable<array<mixed>> of fixed positional argument tuples, each run (before the random inputs) as an explicit example. Defaults to <testMethod>Examples when that method exists. |
$maxDiscards | ?int | NULL | Maximum number of discarded inputs before the property gives up. Null (default) uses ten times the resolved run count. |
$timeoutMs | ?int | NULL | Wall-clock deadline for a single run (random or example) in milliseconds. A body that takes longer fails the property with a DeadlineExceededException naming the offending input — protection against pathological inputs (catastrophic regex, deep recursion, unbounded backoff). Measured after the run returns, so a body that never returns cannot be interrupted; shrink trials are not measured. Null (default) disables the deadline. |
$budgetMs | ?int | NULL | Wall-clock budget for the whole random phase in milliseconds. When it runs out before $runs successful checks complete, the property fails with a TimeBudgetExceededException. Null (default) disables the budget. |