Failure output
What a failure prints is read by people, and by tools: mutastic, coding agents, the proptastic command. So it follows rules, the same in every edition, and this page has all of them, each with a failure that shows it. Reading a failure is the gentler introduction.
The shape
Section titled “The shape”Your assertion’s own message comes first, untouched. Then a blank line, the header, and the facts, their names right-aligned, each value after its name:
Expecting actual: 100to be less than: 100
aSmallBasketCostsUnderAHundred failed after 1 try (seed 0x5eed) shrunk counterexample: prices = [100] pin it: .example(List.of(100)) rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'ShrinkingTest.aSmallBasketCostsUnderAHundred'- The header is
<test> failed after N tries (seed 0x…), orfailed on example N of Mfor a pinned example, which has no seed. - The facts, in this order, each only when it applies:
shrunk counterexample(orcounterexamplewhen it wasn’t shrunk),fails for any,tzdb,pin it,rerun. tzdbis the version of the time zone database, when the input drew a value in a region zone: Dates and times shows one. Replaying a counterexample saved under another version, a!line says so, as the zone’s rules may have changed.rerunis printed when proptastic knows the command that ran the test, and selects exactly that one test.
Stacked
Section titled “Stacked”When a value spans lines, or the counterexample or pin line would pass the width, every fact goes
on a line of its own, its value four spaces in below it. The width is COLUMNS, else 100; the
rerun line doesn’t count, as it’s for copying:
expected: <50> but was: <51>
aTransferWithAFeeKeepsTheTotal failed after 2 tries (seed 0x4f1c2a9e7b3d5f60) shrunk counterexample: aliceHas = 50, bobHas = 0, amount = 50 fails for any: bobHas pin it: .example(/* aliceHas */ 50L, /* bobHas */ 0L, /* amount */ 50L) rerun: PROPTASTIC_SEED=0x4f1c2a9e7b3d5f60 ./gradlew test --tests 'BankAccountTest.aTransferWithAFeeKeepsTheTotal'A value still too wide for its line breaks as Java’s formatter breaks a call: each element on a line of its own, four spaces further in. The pin breaks the same way, and still compiles where it’s pasted:
static Domain<Integer> bigPrices() { return integers().atLeast(50_000).atMost(999_999);}
@Testvoid aLongOrderStaysUnderAMillion() { forAll(lists(bigPrices()).ofSize(atLeast(10))) .check(prices -> assertThat(total(prices)).isLessThan(1_000_000));}Expecting actual: 1000000to be less than: 1000000
aLongOrderStaysUnderAMillion failed after 1 try (seed 0x5eed) shrunk counterexample: prices = [ 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 550000] fails for any: prices pin it: .example( List.of( 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 550000)) rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'LayoutTest.aLongOrderStaysUnderAMillion'Values
Section titled “Values”- For people, then as source. The counterexample shows values as you’d say them,
50,NaN; the pin spells them as Java does,50L,Double.NaN, so it compiles. - Names. With two or more draws, each value in the pin follows a comment naming its draw,
where javac kept the names:
.example(/* aliceHas */ 50L, …). - Records print as the constructor call that makes them, followed by a comment naming each record type’s components. A nested type is named from its top-level class, or by the name the test uses:
expected: <2147485880> but was: <-2147481416>
aTradesValueIsItsQuantityTimesItsPrice failed after 28 tries (seed 0xb6fa8422087bd6db) shrunk counterexample: trade = new Trade("AAPL", Side.BUY, 6520, 329369) // Trade(symbol, side, quantity, priceInCents) pin it: .example(new Trade("AAPL", Side.BUY, 6520, 329369)) rerun: PROPTASTIC_SEED=0xb6fa8422087bd6db ./gradlew test --tests 'DomainsTest.aTradesValueIsItsQuantityTimesItsPrice'- Escaped. A control, format or direction character is written as its escape, never as itself, so a counterexample can’t hide or reorder what’s around it:
@Testvoid aNameHasNoControlCharacters() { forAll(strings().from("ab" + RIGHT_TO_LEFT)) .check(name -> assertFalse(name.contains(RIGHT_TO_LEFT)));}expected: <false> but was: <true>
aNameHasNoControlCharacters failed after 1 try (seed 0x5eed) shrunk counterexample: name = "\u202e" pin it: .example("\u202e") rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'LayoutTest.aNameHasNoControlCharacters'Which characters are escaped doesn’t depend on your JDK: proptastic follows Unicode 16.0.0, so controls, format characters, private-use and unassigned code points, lone surrogates and the line and paragraph separators are escaped the same on Java 17 as on 25, and in every edition.
- No source form. A value proptastic can’t write as Java, such as a class that isn’t a record,
prints its
toString, and the pin is the seed:
Expecting actual: 1000to be less than: 1000
aBasketCostsUnderAThousand failed after 4 tries (seed 0x5eed) shrunk counterexample: basket = Basket[500, 500] pin it: .seed(0x5eed) // no source form for this input rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'PinsTest.aBasketCostsUnderAThousand'Not shrunk
Section titled “Not shrunk”With PROPTASTIC_SHRINK=false, the input as found, under counterexample:
Expecting actual: 2892to be less than: 100
aSmallBasketCostsUnderAHundred failed after 1 try (seed 0x5eed) counterexample: prices = [988, 135, 704, 1000, 65] pin it: .example(List.of(988, 135, 704, 1000, 65)) rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'ShrinkingTest.aSmallBasketCostsUnderAHundred'A pinned example that fails, as written:
Actual and expected should have same size but actual size is: 1while expected size is: 2Actual was: [0]Expected was: [0, 0]
sortBySetKeepsSize failed on example 1 of 1 counterexample: xs = [0, 0]A failure that passed when its input ran again, with a ! line saying so:
expected: <101> but was: <0>
theCacheAnswersTheListPrice failed on try 1, then passed when that input ran again (seed 0x5eed) counterexample: sku = 1 pin it: .example(1) rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'FlakyTest.theCacheAnswersTheListPrice' ! flaky: the same input passed and failed, so the result depends on more than the input: time, shared state, threads or iteration order. A pinned example will be flaky too.A stateful test’s failure leads with what broke, then the steps that remain after shrinking, one a line, and a pin that replays them:
invariant "money is conserved" broke after step 3: withdraw("alice", 1)
theBankKeepsItsBooks failed after 9 tries (seed 0x1) shrunk steps: 1. deposit("bob", 1) 2. transfer("bob", "alice", 1) 3. withdraw("alice", 1) ← bob = 0, alice = 1 pin it: .example( step("deposit", "bob", 1L), step("transfer", "bob", "alice", 1L), step("withdraw", "alice", 1L)) // typed pins come from @StepBuilder rerun: PROPTASTIC_SEED=0x1 ./gradlew test --tests 'StatefulBankTest.theBankKeepsItsBooks'A step that keeps a value says so, var account1 = open(), and the steps after it name it by its
handle; a step that keeps several says which,
open() // keeps account1, account2. Steps from an interface pin as its calls, a handle as
account(1), with a note naming the import they need:
invariant "money is conserved" broke after step 3: transfer(account1, account1, 1)
accountsOpenedAsNeededKeepTheBooks failed after 10 tries (seed 0x1) shrunk steps: 1. var account1 = open() 2. deposit(account1, 1) 3. transfer(account1, account1, 1) ← holds 2, should hold 1 pin it: .example( open(), deposit(account(1), 1L), transfer(account(1), account(1), 1L)) // import static stateful.BranchingStep.* rerun: PROPTASTIC_SEED=0x1 ./gradlew test --tests 'BuiltHandlesTest.accountsOpenedAsNeededKeepTheBooks'Threads
Section titled “Threads”Steps on threads lead with what went wrong, then the interleaving, a column per thread, time going
down, and a pin of a thread(…) per thread. When the threads’ answers fit no order of their
steps, one at a time, the lines under the first say what each thread saw (they saw:), each order
tried and where it stopped fitting (one at a time:; past four, the four that got furthest and a
count of the rest), and which step began before another and ended after it. A lock taken and let
go with nothing in between is one line, locks and unlocks "account"; where a schedule has one
lock, a column names it the first time only:
no order of the threads' steps, one at a time, gives what they saw they saw: thread 1: withdraw(1) → true thread 2: withdraw(100) → true one at a time: withdraw(100) → true, then withdraw(1) → false withdraw(1) → true, then withdraw(100) → false thread 1's withdraw(1) → true began before thread 2's withdraw(100) and ended after it
withdrawalsAtOnceKeepTheBooks failed after 1 try (seed 0x90) shrunk steps: thread 1 thread 2 1. withdraw(1) locks and unlocks "account" paused before it takes "account" 1. withdraw(100) locks and unlocks "account" locks and unlocks → true locks and unlocks → true pin it: .example(thread(step("withdraw", 1L)), thread(step("withdraw", 100L))) // typed pins come from @StepBuilder rerun: PROPTASTIC_SEED=0x90 ./gradlew test --tests 'SharedAccountTest.withdrawalsAtOnceKeepTheBooks'Steps taken first, before the threads start, show
under first, numbered above the columns, and pin as first(…) before the thread(…)s. A first
step that fails leads with step N of the first steps failed: and the step:
no order of the threads' steps, one at a time, gives what they saw they saw: thread 1: withdraw(1) → true thread 2: withdraw(1) → true one at a time: withdraw(1) → true, then withdraw(1) → false thread 1's withdraw(1) → true began before thread 2's withdraw(1) and ended after it
withdrawalsFromAnEmptyAccountKeepTheBooks failed after 2 tries (seed 0x1) shrunk steps: first 1. deposit(1) thread 1 thread 2 1. withdraw(1) locks and unlocks "account" paused before it takes "account" 1. withdraw(1) locks and unlocks "account" locks and unlocks → true locks and unlocks → true pin it: .example( first(step("deposit", 1L)), thread(step("withdraw", 1L)), thread(step("withdraw", 1L))) // typed pins come from @StepBuilder rerun: PROPTASTIC_SEED=0x1 ./gradlew test --tests 'SharedAccountTest.withdrawalsFromAnEmptyAccountKeepTheBooks'A deadlock names what each thread holds and waits for:
deadlock: thread 1 holds "London", waits for "NewYork"; thread 2 holds "NewYork", waits for "London"
theInheritedDeskNeverDeadlocks failed after 1 try (seed 0x2) shrunk steps: thread 1 thread 2 1. move("London", "NewYork", 1) locks "London" paused before it takes "NewYork" 1. move("NewYork", "London", 1) locks "NewYork" waits for "London" waits for "NewYork" pin it: .example( thread(move("London", "NewYork", 1L)), thread(move("NewYork", "London", 1L))) // import static deadlock.BookingStep.* rerun: PROPTASTIC_SEED=0x2 ./gradlew test --tests 'MovesAtOnceTest.theInheritedDeskNeverDeadlocks'A pass on threads says what it searched, and claims no more:
passed on 2 threads, 101 runs (every schedule with up to 2 preemptions: 3,906) · no deadlock · each fits an order of its steps, one at a time how sure: 0 of 100 runs failed, so under 3% of runs drawn this way fail it (95% confidence) why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/Models and specs
Section titled “Models and specs”A property that follows a model leads with the verdict and the model’s version, then where it differed:
does not follow model Desk.canExecute (Java)model Desk.canExecute said true, code said false (outcome fits)
theDeskFollowsTheModel failed after 2 tries (seed 0x5eed) shrunk counterexample: order = new Order(0, 1, 1) // Order(held, quantity, limit) pin it: .example(new Order(0L, 1L, 1L)) rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'DeskFollowsTheModelTest.theDeskFollowsTheModel'A step a spec doesn’t allow says what the step did to the spec’s variables:
does not follow spec Reserve 1 (TLA+)step 2 is not one spec Reserve allows: reserve("B") allowed position = 80, reserved = 15, status = {A=approved, B=rejected, C=new} did position = 80, reserved = 30, status = {A=approved, B=approved, C=new} differs reserved 15 → 30 · status[B] rejected → approved keeps invariants Within, Accounted
aCheckThenExecuteDeskDoesnt failed after 3 tries (seed 0x5eed) shrunk steps: 1. reserve("A") 2. reserve("B") ← position 80, reserved 30, {A=APPROVED, B=APPROVED} pin it: .example(reserve("A"), reserve("B")) // import static spec.ReserveStep.* rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'DeskFollowsTheSpecTest.aCheckThenExecuteDeskDoesnt'An outcome of the model, or an action of the spec, that never came up fails the run, as the tries
checked nothing of it. There’s no counterexample, but the seed the tries were drawn from is named
beside the count, and the rerun line ends it, so the run can be seen again:
model Calendar.isLeap's outcome century (a multiple of 100, not of 400) never came up in 1,000 tries (seed 0x5eed), so following it said nothing of that case: widen the domains, or say why it can't with .unreachable("century", "…") rerun: PROPTASTIC_SEED=0x5eed ./gradlew test --tests 'LeapYearTest.thisCenturyByRule'A pass names the same, the outcomes’ counts, and how sure it is, with where that’s explained the first time a run prints one:
followed model Desk.canExecute on 100 tries (Java) · outcomes fits 100 · breach unreachable (these orders are all far below the limit) how sure: 0 of 100 tries failed, so under 3% of inputs drawn this way fail it (95% confidence) why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/A spec followed by TLC traces, with no graph beside it, names that way in its pass, the steps the runs took and how many were distinct:
followed spec BigCounter sha256:685ac333 on 100 runs (TLC traces: 673 steps, 16 distinct) · actions Increment 322 · Reset 351 · left the model 0% how sure: 0 of 100 runs failed, so under 3% of runs drawn this way fail it (95% confidence) why: https://docs.proptastic.io/concepts/how-sure-is-a-pass/Without PROPTASTIC_TLC where the tests run, the pass says the steps weren’t checked.
A pass whose require couldn’t tell a share either way says so,
passed, but its coverage is incomplete after 6,400 tries, with the facts a failure would give,
unless PROPTASTIC_INCOMPLETE=fail makes it one.
Colour
Section titled “Colour”Where colour is shown, in your terminal or your IDE’s test runner, a failure is coloured; colour is
only added, so without it the text is exactly what’s above. PROPTASTIC_COLOR sets it.
With your test framework shows it.