Skip to content

Keeping an example

A failure’s counterexample is saved in the build directory and tried first next run, until it passes. A clean deletes it, and once the code is fixed nothing keeps checking that input. The input that found a bug is the one most worth checking for ever: pin it as an example, and it runs first, every time, on every machine.

You can paste a failure’s pin it line by hand. proptastic example does it for you, and keeps the code changing only when a person says so: a person pins; a coding agent or CI proposes, and a person accepts.

Each output here is what the command printed on a calendar whose November has 31 days.

Terminal window
proptastic example
Counterexamples ───────────────────────────────────────────────────────
c890c8808 CalendarTest#novemberHas30Days year = 1
pin it: .example(1)
Next: proptastic example c890c8808 · or propose: proptastic example c890c8808 --propose --reason="<why>"

Each counterexample the last run saved, by its id, with the line that pins it.

proptastic example ID puts the pin line into the property’s chain, after its last .example(…), with .via("proptastic: ID") saying where it came from. It then runs that property alone, and says whether the example still fails, as it will until the code is fixed, or passes.

A coding agent, or CI, shouldn’t change your tests unseen. --propose writes the example into .proptastic/proposals.yaml, which is committed, with the reason it’s worth keeping:

Terminal window
proptastic example c890c8808 --propose --reason="November has 30 days in every year"
proposed c890c8808 for CalendarTest#novemberHas30Days, in .proptastic/proposals.yaml:
.example(1).via("proptastic: c890c8808")
for a person to accept, once the pull request is reviewed:
proptastic example c890c8808 --accept
To take it back:
proptastic example c890c8808 --remove

A person reviewing the pull request accepts it:

Terminal window
proptastic example c890c8808 --accept
pinned c890c8808 in src/test/java/calendar/CalendarTest.java:30, CalendarTest#novemberHas30Days:
.example(1).via("proptastic: c890c8808")
and ./gradlew test --rerun --tests calendar.CalendarTest.novemberHas30Days still fails on it, as saved: fix the code, and it's checked first every run until then.
To take it out again:
proptastic example c890c8808 --remove
Terminal window
proptastic example c890c8808 --remove
took out the line pinning c890c8808, src/test/java/calendar/CalendarTest.java:30:
.example(1).via("proptastic: c890c8808")
To put it back, paste it into the chain again.

Every action says how to undo it.

With CI set, pinning and accepting are refused, since CI doesn’t edit source, and the refusal says how to propose it instead:

Terminal window
CI=true proptastic example c890c8808 --accept
proptastic: CI is set, and CI doesn't edit source, so c890c8808 wasn't pinned: pin it on your machine. To propose it for a person to accept instead:
proptastic example c890c8808 --propose --reason="<why>"

proptastic example has every option.

Privacy