Skip to content

API

A property starts from Proptastic's static functions: forAll, and every domain it draws from. The other types are what they return. This reference is written from the API's own doc comments. What's marked @Internal is public only for proptastic's own code, may change in any release, and is left out here. Compatibility says what stays the same from one release to the next.

io.proptastic

proptastic: property-based testing inside a plain test. io.proptastic.Proptastic has every function a property starts from, forAll and the domains it draws from, and the types here are what they return.

AnyDomainclassany(T.class): a domain found from the type, whose record components can each be given a domain of their own: any(Trade.class).with(Trade::quantity, integers().atLeast(1)).
AnyDomain.ComponentinterfaceA record’s component, named by its accessor: Trade::quantity.
ArgumentinterfaceWhat a step’s argument is drawn from, in .step(name, …, body): a Domain; the Handles earlier steps kept, .step("deposit", accounts, amounts(), …); or a domain the state gives, fromState(account -> longs().atLeast(1).atMost(account.balance())).
BigIntegerDomainclassIntegers of any size, BigIntegers: -2^127 to 2^127-1 unless bounded (a bound past it moves the other end a range’s width beyond), the range Rust’s i128 has, so the two editions draw the same values from the same choices: bigIntegers().atLeast(BigInteger.ZERO).
BoundrecordOne end of a size or a length, inclusive: atLeast(1) or atMost(50), as in lists(integers()).ofSize(atLeast(1), atMost(50)).
BytesDomainclassByte strings, byte[]s: bytes().ofSize(atMost(64)).
DateDomainclassCalendar dates, LocalDates: dates().atLeast(LocalDate.of(2026, 1, 1)) .excluding(SATURDAY, SUNDAY).excluding(holidays).
DateTimeDomainclassDates with times of day and no zone, LocalDateTimes: a date as dates() draws it, with its calendar edges, then a time on that date, so a counterexample shrinks toward 2001-01-01T00:00, or the bound nearest it (decision 81).
DecimalDomainclassExact decimals, BigDecimals: decimals().atLeast(BigDecimal.ZERO).places(2).
DomainclassWhere a property’s inputs come from: “for all x in the domain”.
DoubleDomainclassdoubles, all of them unless bounded: doubles().atLeast(0).lessThan(1).
DurationDomainclassSigned lengths of time, Durations, between any two instants of the dates’ window unless bounded: whole seconds most tries, a fraction of a second one try in 8, and about one try in five an edge, zero, a nanosecond, a second, 23 hours, a day or 25 hours, either way.
EncodedDomainclassByte strings drawn as text, base64 or hex: bytes().inBase64().
FloatDomainclassfloats, all of them unless bounded: floats().atLeast(0).lessThan(1).
HandleannotationMarks, in a StepBuilder interface, a value steps make that later steps use, by the name of its Handles: on a step’s method, @Handle("account") long open(), the step keeps what the method returns; on a parameter, void deposit(@Handle("account") long account, long amount), the step draws one the run kept and hasn’t dropped, so its generated method takes no domain for it, .deposit(amounts()).
HandlesclassValues a step makes that later steps use, such as an account it opens: var accounts = handles("account").
IdentifierDomainclassIdentifiers with a check (decision 98): a body drawn by construction, then its check, so every value passes; .mistyped() changes one character so the check catches it, for a validator’s other side.
InstantDomainclassMoments, Instants: a date and a time in UTC, as dateTimes() draws them, in the same window, so a counterexample shrinks toward 2001-01-01T00:00:00Z, or the bound nearest it (decision 81).
IntegerDomainclassints, all of them unless bounded: integers().atLeast(1).atMost(100).
InternalannotationPublic only so proptastic’s own code can reach it, never a test: what the agent’s rewritten code and fuzz’s worker call, what a step builder’s generated classes are built on, and what the commands share with the library.
ListDomainclassLists of an element domain’s values.
LongDomainclasslongs, all of them unless bounded: longs().atLeast(1).atMost(1_000_000).
MapDomainclassMaps from a key domain to a value domain, in the order drawn.
ModelclassA model the code follows, from lean(…) or command(…): a process that says, for each try’s values, what the code should answer, and which of the model’s outcomes that is.
Model.AnswerrecordA model’s answer to one try: which of its outcomes it is, and what the code should answer, written as the code’s answer is (decision 33): answer("leap", true).
Model.OutcomerecordOne of a model’s outcomes, and what it means: outcome("leap", "divisible by 4, not by 100 unless by 400").
Property1classA property over 1 draw, from forAll.
Property1.AnswerinterfaceThe code’s answer to a try’s values, for .follows.
Property1.CheckinterfaceThe property’s body.
Property2classA property over 2 draws, from forAll.
Property2.AnswerinterfaceThe code’s answer to a try’s values, for .follows.
Property2.CheckinterfaceThe property’s body.
Property3classA property over 3 draws, from forAll.
Property3.AnswerinterfaceThe code’s answer to a try’s values, for .follows.
Property3.CheckinterfaceThe property’s body.
Property4classA property over 4 draws, from forAll.
Property4.AnswerinterfaceThe code’s answer to a try’s values, for .follows.
Property4.CheckinterfaceThe property’s body.
Property5classA property over 5 draws, from forAll.
Property5.AnswerinterfaceThe code’s answer to a try’s values, for .follows.
Property5.CheckinterfaceThe property’s body.
Property6classA property over 6 draws, from forAll.
Property6.AnswerinterfaceThe code’s answer to a try’s values, for .follows.
Property6.CheckinterfaceThe property’s body.
PropertyChainclassWhat every forAll(…) chain says besides its examples: .via, .tries and .seed.
ProptasticclassEverything a property says, behind one static import: import static io.proptastic.Proptastic.*;.
Proptastic.Make1interfaceMakes a value from 1 drawn value: a constructor or a method, as Trade::new.
Proptastic.Make2interfaceMakes a value from 2 drawn values: a constructor or a method, as Trade::new.
Proptastic.Make3interfaceMakes a value from 3 drawn values: a constructor or a method, as Trade::new.
Proptastic.Make4interfaceMakes a value from 4 drawn values: a constructor or a method, as Trade::new.
Proptastic.Make5interfaceMakes a value from 5 drawn values: a constructor or a method, as Trade::new.
Proptastic.Make6interfaceMakes a value from 6 drawn values: a constructor or a method, as Trade::new.
RangeDomainclassThe bound words for numbers, all in this one class so they’re easy to rename: integers().atLeast(1).atMost(100).
SetDomainclassSets of an element domain’s values, in the order drawn.
SizedDomainclassA collection’s domain, sized by bounds: ofSize(atLeast(1), atMost(50)), ofSize(atMost(50)), ofSize(n) or nonEmpty().
SourceclassThe source in a named domain, domain(source -> new Trade(source.draw(symbols()), …)): draws values from other domains, in order, from one try’s choices.
SpecclassA TLA+ spec a stateful test follows, from spec(…): every state TLC reached and every step between them, read from its -dump dot,actionlabels file.
StatefulPropertyclassA stateful test, from forAll(steps): .tries, .seed, .id and .example as on any property, then .check(), whose check is the invariants and the steps’ own assertions.
StepBuilderannotationGenerates typed steps for a stateful test from an interface of them: each abstract method is a step, named by the method, its arguments typed by its parameters.
StepsclassA stateful test: the steps that can be taken on a state, in any order, and what holds after every one, from steps(Accounts::new).
Steps.HoldsinterfaceAn invariant: whether it holds of the state.
Steps.PreconditioninterfaceA step’s precondition: whether the state allows the step.
Steps.Step0interfaceA step with nothing drawn.
Steps.Step1interfaceA step with one argument.
Steps.Step2interfaceA step with two arguments.
Steps.Step3interfaceA step with three arguments.
Steps.Step4interfaceA step with four arguments.
Steps.Step5interfaceA step with five arguments.
Steps.Step6interfaceA step with six arguments.
StringDomainclassStrings of Unicode code points, lengths counted in code points.
ThreadedPropertyclassA stateful test’s steps on several threads at once, from forAll(steps).threads(2): .tries, .seed, .id and .example as on any property, then .check().
TimeDomainclassTimes of day, LocalTimes: times().atLeast(LocalTime.of(9, 0)).every( Duration.ofMinutes(15)).

io.proptastic.bounds

The bounds a size takes, atLeast(1) and atMost(50), for lists(integers()).ofSize(atLeast(1), atMost(50)).

BoundsclassThe size and length bounds, behind their own static import: import static io.proptastic.bounds.Bounds.*;, then lists(ops).ofSize(atLeast(1), atMost(50)).

io.proptastic.serials

The serials module (decision 85): dates as spreadsheet serial numbers, for code that reads, writes or converts spreadsheet cells, dates().inSerials(Serial.EXCEL_1900).

SerialenumA system of spreadsheet serial dates, a date and time as a number of days, for dates().inSerials(Serial.EXCEL_1900) (decision 85).

Privacy