Troubleshooting
Most of what goes wrong with a property isn’t a bug in your code: the build didn’t run it, didn’t show what it printed, or ran it with a setting it never saw. This page is arranged by what you see, with what causes it and what to do.
The build ran no properties
Section titled “The build ran no properties”Maven, with a class named some other way. Surefire runs only classes whose names start with
Test or end with Test, Tests or TestCase. Properties in SortProperties aren’t run, and
Maven says nothing of them. Rename the class, or add an <include> to Surefire’s configuration:
Install has it, and With your test framework
shows one for Kotest’s specs.
No @Test. A property runs when your test framework runs the method it’s in. forAll(…)
outside a test method, or in a method the framework doesn’t see, never runs.
No .check(…). forAll(…).example(…) sets a property up; .check(…), or .follows(…) for a
model or a spec, is what runs it.
Gradle shows no counterexample
Section titled “Gradle shows no counterexample”Gradle prints only the type of a failed test’s exception unless told otherwise, and proptastic’s
report is in its message. Set exceptionFormat = FULL in testLogging, as
Install does, and the whole failure shows.
A setting is ignored
Section titled “A setting is ignored”Gradle and -D. ./gradlew test -Dproptastic.seed=0x5eed sets the property in Gradle’s own
JVM, where no test reads it. Use the environment variable, PROPTASTIC_SEED=0x5eed ./gradlew test, or pass it on with systemProperty(…) in the build file.
Settings has each setting’s forms.
A property’s own setting wins. .seed(…) and .tries(…) on a property win over
PROPTASTIC_SEED, though PROPTASTIC_TRIES wins over .tries(…).
The rerun line runs nothing
Section titled “The rerun line runs nothing”After a pass, Gradle calls the test task up to date and runs nothing, whatever the environment
says. After a failure it always runs again, so the rerun: line a failure prints works as printed;
to run a passing property with another seed, add --rerun.
Seeds and replay has both forms of the line.
A failure won’t come back
Section titled “A failure won’t come back”It passed when its input ran again. The failure depends on something besides the input: a field, a cache, a static, the clock. proptastic says so, and doesn’t shrink it:
expected: <101> but was: <0>
theCacheAnswersTheListPrice failed on try 1, then passed when that input ran again (seed 0x5eed) counterexample: sku = 1 pin it: .example(1) rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'FlakyTest.theCacheAnswersTheListPrice' ! flaky: the same input passed and failed, so the result depends on more than the input: time, shared state, threads or iteration order. A pinned example will be flaky too.Make whatever outlives a try new inside check. Shrinking
has more.
It was replayed, and now passes. A failure’s counterexample is saved and tried first next run,
until it passes. If it passes, the bug is fixed or the input no longer means what it did; the seed
on the failure’s rerun: line still draws the run that found it.
The seed is refused
Section titled “The seed is refused”A seed is 0x and hex digits, as a failure prints it:
proptastic: the system property proptastic.seed is 12345, which isn't a seed. Seeds are 0x and hex digits, as failures print them. PROPTASTIC_SEED=0x12345 ./gradlew test --tests 'SeedsTest.aDecimalSeed' (or 0x3039, if 12345 was decimal)A run stops before it checks anything
Section titled “A run stops before it checks anything”Most of what’s drawn is thrown away, by a filter or an assume(…):
aRoundLotIsAWholeNumberOfHundreds failed a health check (seed 0x5eed) filter: filters rejected 1,628 of the 1,728 values they drew in the first 100 tries, over 3 in 4 rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'HealthTest.aRoundLotIsAWholeNumberOfHundreds' ! build values that meet the filter, in place of discarding the rest ! or say why it's fine: .allow("filter", "…")Draw the values you want rather than filtering for them; Health checks
has each check and .allow(…).
A case it must check came up too rarely, under require(…), or a model’s outcome or a spec’s
action never came up at all. Classify and require and
Errors say what to do.
The proptastic command, by exit status
Section titled “The proptastic command, by exit status”The command’s exit status says what kind of thing went wrong, and what it prints says which. Each error has a code, on Command errors, with a command that stops with it.
1: a property has a counterexample, which is the command working: read the failure, fix the
code, and keep the example. It’s also 1 when example was refused or
its pinned line doesn’t compile, such as with CI set.
2: a mistake in the command, a file or the environment. An option the command doesn’t take, an id that names no counterexample, no project where it looked. The message says what it read and the command to run instead; Command errors has each.
3: something failed before any property ran. The build, or a test that isn’t a property,
failed first, so nothing was checked: run your build’s own command to see why
(host-failed). For fuzz, a pinned example or a saved
counterexample failed before the search began, which a plain run shows first, or an input hung, its
input written to fuzz/hang-… in proptastic’s directory.
4: proptastic itself went wrong. That’s a bug in proptastic, not your tests: please report it, with what the command printed.
130: stopped with Ctrl-C. run stops the build. fuzz says what it searched and keeps the
corpus:
proptastic fuzz --only=aShortHeaderIsNonesearched 1.0s · 30,123 tries · 3 of 43 branches in codec · stopped with Ctrl-C, nothing foundSomething else
Section titled “Something else”Errors has every message proptastic gives other than a counterexample, and Reading a failure every line of one.