Skip to content

CounterExample

Rasuvaeff\PropertyTesting\CounterExample

ClassPackage: property-testing-coreSourceVersion: v0.1.0-12-g86ead85

Minimal failing input for a property, captured at falsification time.

Carries both the original (randomly generated) counterexample and the shrunk (minimised) one, plus the seed needed to reproduce the run.

Constructor

php
__construct(
    int $seed,
    int $runsBeforeFailure,
    array<string,mixed> $originalArguments,
    array<string,mixed> $shrunkArguments,
    int $shrinkSteps = 0,
    ?\Throwable $failure = NULL,
    int $skips = 0,
    int $shrinkTrials = 0,
)
ParameterTypeDefaultDescription
$seedintrequiredSeed of the run that first failed (pass it to Property to reproduce).
$runsBeforeFailureintrequiredNumber of successful (non-discarded) runs before the failure.
$originalArgumentsarray<string,mixed>requiredRandomly generated arguments that first failed.
$shrunkArgumentsarray<string,mixed>requiredMinimised arguments that still fail.
$shrinkStepsint0Number of accepted shrink steps between the original and the minimised arguments.
$failure?\ThrowableNULLThe assertion or exception reported by the failing run.
$skipsint0Number of runs discarded via Assume::that() before the failure.
$shrinkTrialsint0Total number of shrink candidates tried (accepted and rejected).

Methods

toArray()

php
toArray(): array

Machine-readable representation suitable for reporters and serialization.

toJson()

php
toJson(bool $pretty = false): string

toExamplesCode()

php
toExamplesCode(string $methodName = 'propertyExamples'): string