Skip to content

GaveUpException ​

Rasuvaeff\PropertyTesting\GaveUpException

Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2

Extends: RuntimeException

Implements: Throwable, Stringable, PropertyTestingException

Thrown (as the failure of a property) when discarded inputs — or runs the environment refused — exceed their budget before the requested number of successful checks completes. It exposes successful, discarded, skipped and total attempt counts so the result cannot hide a weak input distribution.

The two budgets are separate, and so are the two messages. A discard is a statement about the input, and the fix is almost always to construct valid inputs directly (e.g. Gen::flatMap() / Gen::draw()) rather than generating broadly and discarding. A skip is a statement about the machine, where narrowing the generators would achieve nothing at all.

Constructor ​

php
__construct(
    string $propertyName,
    int $requiredRuns,
    int $successfulRuns,
    int $discardedRuns,
    int $attempts,
    int $maxDiscards,
    int $skippedRuns = 0,
    bool $exhaustedBySkips = false,
    ?int $maxSkips = NULL,
)
ParameterTypeDefaultDescription
$propertyNamestringrequiredProperty that gave up, as the adapter named it.
$requiredRunsintrequiredSuccessful checks the configuration asked for.
$successfulRunsintrequiredSuccessful checks completed before the budget ran out.
$discardedRunsintrequiredRuns discarded via Assume::that() — the input left the domain.
$attemptsintrequiredBodies executed in total, discarded and skipped ones included.
$maxDiscardsintrequiredCap the discard budget was measured against.
$skippedRunsint0Runs the environment refused (a missing dependency, a skipped lifecycle hook).
$exhaustedBySkipsboolfalseWhich budget ran out: the skips' one, or the discards'. It selects the message, because the two have no advice in common.
$maxSkips?intNULLCap the skip budget was measured against — equal to $maxDiscards whenever the caller configured a maxDiscards, and smaller when the two were left implicit. Null means the two budgets were not told apart; the message then falls back to $maxDiscards rather than printing a cap nobody measured against.