Skip to content

ThreadedProperty

class in io.proptastic

class ThreadedProperty<S>

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().

Only one thread runs at a time; proptastic switches between them at points it sees: before each step, and where a thread takes a Proptastic#lock. Each try runs every schedule with at most two preemptions, fewest first. It fails on a deadlock, on an invariant broken after the threads’ steps, on a step’s own failure, and when no order of the steps, one at a time on a new state, gives what the threads saw (Proptastic#record) and leaves the state saying what the threads left it saying.

Parameters

<S>the state the threads share

Methods

example

ThreadedProperty<S> example(Object... threads)

Each thread’s steps to take, before the random tries, as a failure’s pin it: line gives them: .example(thread(step("withdraw", 60L)), thread(step("withdraw", 60L))), after a first(…) of the steps taken before the threads, if any. Every schedule is tried, as for a drawn try.

check

void check()

Runs it now: throws with the shrunk steps and their interleaving if a schedule goes wrong. A pass prints what it searched and checked, and how sure it is.

Privacy