Skip to content

Commit 9c6a6a6

Browse files
committed
Added Footnotes.addAfterFailure(..) to user guide.
See #310
1 parent 3ccb8f7 commit 9c6a6a6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

documentation/src/docs/include/writing-properties.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public class FootnotesExamples {
177177
```
178178

179179
Unlike standard reporting, the footnotes feature must be explicitly enabled through
180-
the annotation `EnableFootnotes`, which can be added to container classes or individual property methods.
180+
the annotation `@EnableFootnotes`, which can be added to container classes or individual property methods.
181181
Now you can add a parameter of type `net.jqwik.api.footnotes.Footnotes` to a property method
182182
or a lifecycle method annotated with either `@BeforeTry` or `@AfterTry`.
183183
The footnote string will then be part of the sample reporting:
@@ -200,6 +200,10 @@ Original Sample
200200
#1 399322
201201
```
202202

203+
For footnotes that require significant computation you can also use
204+
`Footnotes.addAfterFailure(Supplier<String> footnoteSupplier)`.
205+
Those suppliers will only be evaluated if the property fails, and then as early as possible.
206+
Mind that this evaluation can still happen quite often during shrinking.
203207

204208
### Optional `@Property` Attributes
205209

documentation/src/test/java/net/jqwik/docs/footnotes/FootnotesExamples.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ void differenceShouldBeBelow42(@ForAll int number1, @ForAll int number2, Footnot
1515
Assertions.assertThat(difference).isLessThan(42);
1616
}
1717

18+
@Property
19+
void lazyFootnotes(@ForAll int anInt, @ForAll boolean shouldFail, Footnotes footnotes) {
20+
footnotes.addAfterFailure(() -> "anInt=" + anInt);
21+
footnotes.addAfterFailure(() -> "shouldFail=" + shouldFail);
22+
Assertions.assertThat(shouldFail).isFalse();
23+
}
24+
1825
}

0 commit comments

Comments
 (0)