CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/jqwik-testing

Authors property-based tests for the JVM (Java + Kotlin) using jqwik - wires `@Property` test methods, `@ForAll` parameter annotations, `Arbitraries.integers/strings/etc` generators, custom `@Provide` arbitraries, and the JUnit 5 platform integration. Use when a JVM project needs PBT - alternative to JUnit-QuickCheck and Vavr's property-checking; tightly integrates with JUnit 5 so property tests run alongside conventional unit tests in the same Maven / Gradle pipeline.

75

Quality

94%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

jqwik-reference.mdreferences/

jqwik reference

Full lookup tables and maintenance notes for jqwik-testing. Source: jqwik.net.

Version

Pinned to jqwik 1.9.3 (latest at source-fetch); the artifact pulls in the JUnit 5 platform dependency transitively. Check jqwik.net before bumping.

Constraint annotations

In net.jqwik.api.constraints.*:

AnnotationPurpose
@IntRange(min, max)Integers in range
@LongRange(min, max)Longs in range
@DoubleRange(min, max)Doubles in range
@StringLength(min, max)Strings of bounded length
@AlphaChars / @NumericCharsString character class
@Size(min, max)Collection size
@NotEmptyNon-empty collection / string
@NotBlankNon-whitespace string
@EmailEmail-shaped string
@MinList / @MaxListList bounds
@UniqueElementsUnique-element collections
@Positive / @NegativePositive / negative number

Arbitraries catalog

Arbitraries.integers()                       // any int
    .between(0, 100)                         // bounded
    .greaterOrEqual(0);                       // half-bounded

Arbitraries.strings()                        // any string
    .alpha()                                  // alphabetic only
    .ofLength(8);                             // fixed length

Arbitraries.of(Status.ACTIVE, Status.SUSPENDED, Status.NOT_VERIFIED);   // enum-like

Arbitraries.subsetOf(allRoles);              // subset of a known set

For collections:

Arbitraries.integers().list()                // List<Integer>
    .ofMinSize(1).ofMaxSize(100);

Arbitraries.strings().set();                  // Set<String>

Arbitraries.maps(
    Arbitraries.strings().alpha(),
    Arbitraries.integers().between(0, 100)
);

Anti-patterns

Anti-patternWhy it failsFix
Returning void without assertionsTest always passes; property is silent.Return boolean OR throw on failure (e.g. JUnit assertTrue).
@Provide arbitrary that filters most casesDiscard ratio exceeded; jqwik fails the property.Constrain at the Arbitrary level (Step 3 annotations + .between(...)).
Sharing mutable state across @Property iterationsTest depends on iteration order; flaky.Construct fresh state per call (within the property method body).
Hard-coded seed in production propertyLoses randomization; misses regressions.Random seed locally; fixed seed in CI only (Step 7).
tries = 100_000 on a slow propertyCI never finishes.Budget per total runtime / tries.
Asserting on specific values inside the propertyDefeats PBT.Properties assert relationships.
Skipping @Provide for one-off domain objectsInline construction is verbose; harder to reuse.Move to @Provide even for one-property arbitraries.

Limitations

  • JVM startup cost. Each property test pays JVM start; 1000 iterations of fast tests are still seconds, not milliseconds.
  • Shrinking complex types is slow. BOUNDED shrinking caps iterations; OFF skips entirely.
  • Kotlin support requires extra setup. Per jqwik.net, Kotlin is supported but requires the jqwik-kotlin extension.
  • No native async support. Test reactive / coroutine code through runBlocking (Kotlin) or explicit Future.get().
  • JUnit 5 only. No JUnit 4 platform integration.

SKILL.md

tile.json