Skip to content

How a run works

The other concept pages each take one part of a run. This page puts them in order, so you can see where each fits, and where to look when a run does something you didn’t expect.

When a test calls forAll(…).check(…), proptastic:

  1. Runs the examples pinned with .example(…), in order. One that fails is reported as it is, without shrinking.
  2. Replays the counterexample the last run saved, if there is one (Seeds and replay). If it still fails, that’s the failure, and it stays saved; if it passes, the file is deleted.
  3. Picks the seed: the property’s .seed(…), else PROPTASTIC_SEED, else a new one. It records the run in build/proptastic/properties.json.
  4. Runs the corpus, the inputs kept from earlier counterexamples, if the property has any.
  5. Runs the tries: 100 random ones unless .tries(…), PROPTASTIC_TRIES or the profile says otherwise (How values are drawn). With .exhaustively() it runs every value of a small domain instead, once each. A property that calls target(score) climbs toward the inputs that score highest as it goes. While they run, the health checks watch for a filter that rejects most inputs, inputs that are too large, and drawing that’s too slow.
  6. Checks what it was told to require: while it can’t yet tell whether a require label came up often enough, it runs more tries, up to 64 times as many; it fails when the label is surely too rare, and says the label is incomplete when it still can’t tell.

If any input fails, from step 1 to 5, proptastic:

  1. Runs it once more. If it passes, the failure is flaky, and it’s reported as found.
  2. Shrinks it to the smallest input that fails the same way (Shrinking).
  3. Saves it, so the next run tries it first.
  4. Checks which values mattered (Which values mattered).
  5. Reports it, in the shape Reading a failure explains, as the message of an assertion failure your test framework reports as it does any other.

Whether it passes or fails, the run writes an event for the property, a JSON file under build/proptastic/events/ that a tool can read. A pass prints nothing, unless the property follows a model or a spec, or runs on threads, which say what they checked and how sure the pass is, or its require couldn’t tell, which it says as an incomplete pass.

Privacy