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.
AnyDomain | class | any(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.Component | interface | A record’s component, named by its accessor: Trade::quantity. |
Argument | interface | What 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())). |
BigIntegerDomain | class | Integers 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). |
Bound | record | One end of a size or a length, inclusive: atLeast(1) or atMost(50), as in lists(integers()).ofSize(atLeast(1), atMost(50)). |
BytesDomain | class | Byte strings, byte[]s: bytes().ofSize(atMost(64)). |
DateDomain | class | Calendar dates, LocalDates: dates().atLeast(LocalDate.of(2026, 1, 1)) .excluding(SATURDAY, SUNDAY).excluding(holidays). |
DateTimeDomain | class | Dates 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). |
DecimalDomain | class | Exact decimals, BigDecimals: decimals().atLeast(BigDecimal.ZERO).places(2). |
Domain | class | Where a property’s inputs come from: “for all x in the domain”. |
DoubleDomain | class | doubles, all of them unless bounded: doubles().atLeast(0).lessThan(1). |
DurationDomain | class | Signed 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. |
EncodedDomain | class | Byte strings drawn as text, base64 or hex: bytes().inBase64(). |
FloatDomain | class | floats, all of them unless bounded: floats().atLeast(0).lessThan(1). |
Handle | annotation | Marks, 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()). |
Handles | class | Values a step makes that later steps use, such as an account it opens: var accounts = handles("account"). |
IdentifierDomain | class | Identifiers 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. |
InstantDomain | class | Moments, 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). |
IntegerDomain | class | ints, all of them unless bounded: integers().atLeast(1).atMost(100). |
Internal | annotation | Public 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. |
ListDomain | class | Lists of an element domain’s values. |
LongDomain | class | longs, all of them unless bounded: longs().atLeast(1).atMost(1_000_000). |
MapDomain | class | Maps from a key domain to a value domain, in the order drawn. |
Model | class | A 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.Answer | record | A 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.Outcome | record | One of a model’s outcomes, and what it means: outcome("leap", "divisible by 4, not by 100 unless by 400"). |
Property1 | class | A property over 1 draw, from forAll. |
Property1.Answer | interface | The code’s answer to a try’s values, for .follows. |
Property1.Check | interface | The property’s body. |
Property2 | class | A property over 2 draws, from forAll. |
Property2.Answer | interface | The code’s answer to a try’s values, for .follows. |
Property2.Check | interface | The property’s body. |
Property3 | class | A property over 3 draws, from forAll. |
Property3.Answer | interface | The code’s answer to a try’s values, for .follows. |
Property3.Check | interface | The property’s body. |
Property4 | class | A property over 4 draws, from forAll. |
Property4.Answer | interface | The code’s answer to a try’s values, for .follows. |
Property4.Check | interface | The property’s body. |
Property5 | class | A property over 5 draws, from forAll. |
Property5.Answer | interface | The code’s answer to a try’s values, for .follows. |
Property5.Check | interface | The property’s body. |
Property6 | class | A property over 6 draws, from forAll. |
Property6.Answer | interface | The code’s answer to a try’s values, for .follows. |
Property6.Check | interface | The property’s body. |
PropertyChain | class | What every forAll(…) chain says besides its examples: .via, .tries and .seed. |
Proptastic | class | Everything a property says, behind one static import: import static io.proptastic.Proptastic.*;. |
Proptastic.Make1 | interface | Makes a value from 1 drawn value: a constructor or a method, as Trade::new. |
Proptastic.Make2 | interface | Makes a value from 2 drawn values: a constructor or a method, as Trade::new. |
Proptastic.Make3 | interface | Makes a value from 3 drawn values: a constructor or a method, as Trade::new. |
Proptastic.Make4 | interface | Makes a value from 4 drawn values: a constructor or a method, as Trade::new. |
Proptastic.Make5 | interface | Makes a value from 5 drawn values: a constructor or a method, as Trade::new. |
Proptastic.Make6 | interface | Makes a value from 6 drawn values: a constructor or a method, as Trade::new. |
RangeDomain | class | The bound words for numbers, all in this one class so they’re easy to rename: integers().atLeast(1).atMost(100). |
SetDomain | class | Sets of an element domain’s values, in the order drawn. |
SizedDomain | class | A collection’s domain, sized by bounds: ofSize(atLeast(1), atMost(50)), ofSize(atMost(50)), ofSize(n) or nonEmpty(). |
Source | class | The source in a named domain, domain(source -> new Trade(source.draw(symbols()), …)): draws values from other domains, in order, from one try’s choices. |
Spec | class | A TLA+ spec a stateful test follows, from spec(…): every state TLC reached and every step between them, read from its -dump dot,actionlabels file. |
StatefulProperty | class | A 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. |
StepBuilder | annotation | Generates 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. |
Steps | class | A 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.Holds | interface | An invariant: whether it holds of the state. |
Steps.Precondition | interface | A step’s precondition: whether the state allows the step. |
Steps.Step0 | interface | A step with nothing drawn. |
Steps.Step1 | interface | A step with one argument. |
Steps.Step2 | interface | A step with two arguments. |
Steps.Step3 | interface | A step with three arguments. |
Steps.Step4 | interface | A step with four arguments. |
Steps.Step5 | interface | A step with five arguments. |
Steps.Step6 | interface | A step with six arguments. |
StringDomain | class | Strings of Unicode code points, lengths counted in code points. |
ThreadedProperty | class | A 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(). |
TimeDomain | class | Times 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)).
Bounds | class | The 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).
Serial | enum | A system of spreadsheet serial dates, a date and time as a number of days, for dates().inSerials(Serial.EXCEL_1900) (decision 85). |
|---|