ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and shared lessons, time-to-delivery measurement, a library of 140 verification techniques and 20 recipes, personal data kept outside the clone, and releases with rollback. Standard library only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
3.2 KiB
3.2 KiB
id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
| id | title | answers | rung | section | languages | kinds | cost | detect | ran_here | verified |
|---|---|---|---|---|---|---|---|---|---|---|
| jqwik | Property testing on the JVM with jqwik | Does this Java or Kotlin code hold its law for generated inputs, and what is the smallest failing sample? | 2 | many-inputs | java, kotlin | general, parsing, money, state-machine | medium | java -version | no | docs |
Use when
- JVM code has a law that must hold for all inputs and you run tests with Gradle or Maven.
- You want shrinking, replayable seeds and generators built from annotations.
Do not use when
- The author asks agents not to use it: since version 1.10 the jqwik user guide has an "Anti-AI Usage Clause" saying "This project is not meant to be used by any “AI” coding agents at all" and adding that the test engine prints a line to stdout on every run telling agents not to use the library; the main JVM alternative is Kotest's property testing (
io.kotest:kotest-property, Kotlin API, actively released), and for plain Javajunit-quickcheckexists but has had no commits since 2024. - You need coverage-guided search for a parser. Use
jazzer. - The project is locked to JUnit 4 only; jqwik runs as its own JUnit Platform engine.
Set up
Gradle (versions as in the jqwik user guide at the time of writing; check for newer):
testImplementation "net.jqwik:jqwik:1.10.2"
test { useJUnitPlatform { includeEngines 'jqwik' } }
Maven: dependency net.jqwik:jqwik:1.10.2, scope test. Add -parameters to
the Java compiler flags so failure reports show argument names.
Minimal example
import net.jqwik.api.*;
class RoundTripProperties {
static String encode(byte[] b) { return java.util.HexFormat.of().formatHex(b); }
static byte[] decode(String s) { return java.util.HexFormat.of().parseHex(s); }
@Property(tries = 1000)
boolean roundTrips(@ForAll byte[] data) {
return java.util.Arrays.equals(decode(encode(data)), data);
}
}
Run
./gradlew test # or: mvn test
Passing looks like: the build succeeds, exit 0, the test report shows the property
with tries = 1000 and no failures.
Failure shows Shrunk Sample (N steps) and Original Sample plus a seed; the
build exits non-zero. By default the next run tries the failing sample first
(afterFailure = SAMPLE_FIRST); jqwik keeps this in a local database file, so check
whether your build wipes it. Reproduce explicitly with @Property(seed = "...").
As a contract check
{"id": "prop-round-trip-jvm", "claim": "decode(encode(x)) equals x for generated byte arrays", "kind": "parsing", "rung": 2, "cmd": "./gradlew test --tests 'RoundTripProperties'", "expect": {"exit": 0}, "timeout_s": 900, "tier": "deep"}
What a pass does not prove
- It samples 1000 tries by default; edge cases (empty, extremes) are favoured but not exhaustive.
- A fixed
seedleft in committed code freezes the sample; usewhenFixedSeed = FAILto forbid it. - If the engine is not on the test classpath the property is silently never run: confirm the report lists it. Break the code once and see it fail.
- Not run here (no JDK version is set on this machine). Coordinates, annotations and the shrinking output are from the user guide; the failure-database location was not confirmed.