Build plugins
Your build runs your properties without anything else, but the jobs around them, making a setting
reach the tests, searching for longer, keeping a counterexample, need the proptastic command,
which is one more thing to install on every machine and CI image. A Java project can skip it: the
Gradle plugin and the Maven plugin run the same five commands from the build itself, run,
fuzz, explain, example and corpus, and print what the command prints, with every command
they offer written as your build takes it. The command stays the way in for the other editions.
Every output on this page was captured from a real run of the plugin, on a project of two properties (Gradle) and on the repository’s Maven sample.
Add the plugin
Section titled “Add the plugin”plugins { java id("io.proptastic") version "1.0.0"}
proptastic { tries = "200"}The tasks are proptasticRun, proptasticFuzz, proptasticExplain, proptasticExample and
proptasticCorpus, in the group proptastic. The proptastic { } block takes each
setting by its name in camel case without PROPTASTIC_: seed, tries,
corpusRecord. The plugin sets each on every test task as its variable, so ./gradlew test runs
with them too, and a changed setting runs the tests again.
<plugin> <groupId>io.proptastic</groupId> <artifactId>proptastic-maven-plugin</artifactId> <version>1.0.0</version> <extensions>true</extensions> <configuration> <tries>200</tries> </configuration></plugin>The goals are proptastic:run, proptastic:fuzz, proptastic:explain, proptastic:example and
proptastic:corpus. <extensions>true</extensions> makes the plugin a build extension: it sets
each setting in its <configuration>, named as Gradle’s, on Surefire and Failsafe, so ./mvnw test runs with them too; and a goal runs the phase it needs first, so ./mvnw proptastic:run
compiles and runs the tests it answers of.
Options
Section titled “Options”Each of the command’s options is a property, named in camel case: --only=X is
-Pproptastic.only=X on Gradle and -Dproptastic.only=X on Maven, --no-shrink is
-Pproptastic.noShrink. The words a command takes are properties too: explain’s property and
outcome are proptastic.property and proptastic.outcome, and example’s id is proptastic.id.
A property beats the build file, as an option beats a setting. A repeated option takes its values
a comma apart: -Pproptastic.only=sortKeepsSize,sortIsOrdered.
Running the properties
Section titled “Running the properties”The first run runs every test and registers the properties; later runs run only those, through the build’s own test tasks, forced to run, and a failure is said once, in the summary.
./gradlew proptasticRun -Pproptastic.seed=0x5eed Failed ────────────────────────────────────────────────────────────────
✗ SortTest#sortKeepsSize counterexample ca87c5637 expected: <2> but was: <1>
sortKeepsSize failed after 1 try (seed 0x5eed) shrunk counterexample: xs = [0, 0] pin it: .example(List.of(0, 0)) rerun: ./gradlew proptasticRun -Pproptastic.only='com.example.SortTest#sortKeepsSize()' -Pproptastic.seed=0x5eed
Next: ./gradlew proptasticRun -Pproptastic.only='com.example.SortTest#sortKeepsSize()' -Pproptastic.seed=0x5eed
Properties ✓ 1 passed · ✗ 1 failed (2) Ran ./gradlew proptasticRun -Pproptastic.seed=0x5eed Reports build/proptastic/report/report.json · build/proptastic/report/index.html
registered 2 properties; later runs run only those./mvnw proptastic:run -Dproptastic.seed=0x5eed Failed ────────────────────────────────────────────────────────────────
✗ SurefireProperties#aFailurePrintsMavensRerunLine counterexample ca1714346 expected: <2> but was: <1>
aFailurePrintsMavensRerunLine failed after 2 tries (seed 0x5eed) shrunk counterexample: xs = [0, 0] pin it: .example(List.of(0, 0)) rerun: ./mvnw proptastic:run -Dproptastic.only='com.example.SurefireProperties#aFailurePrintsMavensRerunLine()' -Dproptastic.seed=0x5eed
Next: ./mvnw proptastic:run -Dproptastic.only='com.example.SurefireProperties#aFailurePrintsMavensRerunLine()' -Dproptastic.seed=0x5eed
Properties ✓ 4 passed · ✗ 1 failed (5) Ran ./mvnw proptastic:run -Dproptastic.seed=0x5eed Reports target/proptastic/report/report.json · target/proptastic/report/index.html
registered 5 properties; later runs run only thoseThe rerun: line is the plugin’s own: it sets PROPTASTIC_COMMANDS on the tests, so the library
writes it the build’s way. In a module, the line names it: ./gradlew :core:proptasticRun or
./mvnw -pl core proptastic:run. Choosing properties by name runs only theirs:
./gradlew proptasticRun -Pproptastic.only=sortIsOrdered Properties ✓ 1 passed (1) Ran ./gradlew proptasticRun -Pproptastic.only=sortIsOrdered Reports build/proptastic/report/report.json · build/proptastic/report/index.htmlThe other commands
Section titled “The other commands”Each prints what the command prints, as its guide shows it, and offers the next command the
build’s way. explain reads the last run and runs no test unless a property has none:
./mvnw proptastic:explain ✓ CounterProperties#aCounterOfAdditionsNeverGoesBelowZero passed 100 tries · com/example/CounterProperties.java:27 ✓ ListsProperties#reversesTwice passed 100 tries · com/example/ListsProperties.java:14 ✓ ListsProperties#sortsAsTheJdkDoes passed 100 tries · com/example/ListsProperties.java:20 ✗ SurefireProperties#aFailurePrintsMavensRerunLine failed · counterexample ca1714346 · com/example/SurefireProperties.java:22 ✓ SurefireProperties#eventsGoUnderTarget passed 5 tries · com/example/SurefireProperties.java:37
Next: ./mvnw proptastic:explain -Dproptastic.property='CounterProperties#aCounterOfAdditionsNeverGoesBelowZero'example lists what’s waiting, and pins one before the build compiles the tests, then replays
the property’s examples alone (Keeping a counterexample):
./gradlew proptasticExample Counterexamples ───────────────────────────────────────────────────────
ca87c5637 SortTest#sortKeepsSize xs = [0, 0] pin it: .example(List.of(0, 0))
Next: ./gradlew proptasticExample -Pproptastic.id=ca87c5637 · or propose: ./gradlew proptasticExample -Pproptastic.id=ca87c5637 -Pproptastic.propose -Pproptastic.reason="<why>"fuzz searches as Searching longer says, and corpus keeps the
inputs as Keeping the corpus says. .proptastic/fuzz/ is Gradle’s fuzz task’s
output, and the corpus and the settings are each test task’s inputs, so a change to one runs the
tests again.
Models
Section titled “Models”A test that follows a model needs the model built first: a TLA+ spec’s
state graph dumped by TLC, a Lean model built by Lake. Both plugins do it from where models go,
models/tla and models/lean, so the build needs no tasks of its own. Gradle’s tasks are below;
Maven’s goals are proptastic:tlc, proptastic:tlc-check and proptastic:lake-build, and the
plugin, as a build extension, runs lake-build and fetches TLC before the tests and tlc-check at
verify, in each module that has models.
-
proptasticTlcmodel-checks each spec a stateful test follows, amodels/tla/<Name>.tlawith a<Name>.cfgbeside it, and writes its state graph beside it,models/tla/<Name>.dot, for you to commit. A spec with more than 10,000 states gets no graph, as one that big isn’t worth committing: TLC stops there, the task deletes any graph beside the spec and says why, and a test follows the spec by TLC traces. -
proptasticTlcCheck, whichcheckruns (Maven’stlc-check, atverify), fails until each graph there is the one TLC dumps, and that a spec with no graph has none there, so a spec and the graph its tests follow can’t drift apart:> proptastic: models/tla/Counter.dot isn't the graph TLC dumps from the spec: ./gradlew proptasticTlc writes it again, to commit -
proptasticLakeBuildrunslake buildinmodels/leanbefore the tests, once for each change to the Lean sources. Without Lean installed it says how to install it and the build goes on; a property that follows a Lean model that isn’t built still fails, naming how to build it.
TLC is fetched into the build, at the version the plugin pins and checked against its checksum,
only when there’s a spec to check. The plugin then sets PROPTASTIC_TLC on every test task, so a
failure says which of the spec’s invariants the code broke. Set tlc in proptastic { }, or in
the Maven plugin’s <configuration>, to use a TLC of your own instead.
Where the plugins differ from the command
Section titled “Where the plugins differ from the command”The plugins are held to the same contract as the command, and print the same thing for the same files. Where the command decides by the terminal, or the build tool decides, they differ:
- The format is decided once.
conciseunless theformatoption says otherwise, oragentunderPROPTASTIC_AGENT; colour only withcolor=alwaysorFORCE_COLOR. - A fuzz run below JDK 24 is one round a build. The worker that searches coverage-guided needs
the agent, which needs JDK 24 or later on the test task (Gradle) or Maven’s own JDK (Maven). Below
it, the test task runs the properties once, as long as
forsays, or a minute, and the first line says why the search isn’t coverage-guided. The command runs round after round instead. - A search says how it goes in lines, not a bar. A build’s log isn’t a terminal, so the plugin writes a heartbeat line where the command draws its progress bar.
- A cancelled build says what it stopped where the build tool shows it. On Gradle, Ctrl-C ends the terminal’s client at once, so the stopped message reaches the daemon’s log and the IDE’s run, not that terminal. On Maven, it’s printed as Maven stops.
- A pin that doesn’t compile is taken out after the build’s own failure. The build fails compiling the tests before the plugin can answer; the plugin then takes the line out again and says so below the compiler’s errors, and the build’s exit is the build tool’s.
- Maven fetches a JUnit Platform Launcher for the fuzz worker when the project names none, of the version of its JUnit Platform engine: Surefire brings its own, so a Maven project seldom does.