Testing Problem
I'm using jqwik with much delight to test Apache Beam pipelines, i.e. integration tests using PBT. The inputs and outputs are generally large data structures, and bugs are found with sequences of inputs that trigger certain behaviour (e.g. a sequence of input elements interspersed with clock commands that cause time to pass in the test).
When jqwik finds a failing example it prints the minimal example input (after shrinking) along with the original input, I guess using toString? In any case, with these large structures, often being lists of large structures, the output is very hard to digest.
In my case, it can look something like the following, but with the lines being way longer:
sample = [[ElementReceived(timestampedValue=TimestampedValue(SuperLargeThing(...), 1970-01-01T00:00:00.001Z), ProcessingTimePassed(duration=PT1800S)], ...]
original-sample = [... far more SuperLargeThings ... ]
Suggested Solution
I'd like to have structures pretty-printed over multiple lines in order to make them more readable and easy troubleshooting. I can't suggest any universal pretty-printing solution for the JVM, so I'm thinking that this should be up to the user. Use toString by default, and let the user override with a custom printer.
In Haskell Hedgehog (which I'm most familiar with), there's an alternative to forAll called forAllWith, that takes a function to convert your generated value to a string. In jqwik, this is handled with method arguments and annotations, so I'm not sure what would be a suitable counterpart. Maybe there's some convention on the JVM (or in Java, specifically) that could be used?
I'm leaving the solution part of this issue intentionally vague.
Discussion
Another concern, which might be a separate issue altogether, is pretty-printing in assertions. The same pretty-printing solution used for examples would be nice to use in AssertJ or whatever assertions used. Ideally, I'd like to have pretty-printed data structures and diffs (like git diff). Example from an article I wrote:

I'm not sure if there exists any library for doing pretty-printed diffs that could be used both for printing examples and in assertions.
Looking forward to getting some feedback on this!
Testing Problem
I'm using jqwik with much delight to test Apache Beam pipelines, i.e. integration tests using PBT. The inputs and outputs are generally large data structures, and bugs are found with sequences of inputs that trigger certain behaviour (e.g. a sequence of input elements interspersed with clock commands that cause time to pass in the test).
When jqwik finds a failing example it prints the minimal example input (after shrinking) along with the original input, I guess using
toString? In any case, with these large structures, often being lists of large structures, the output is very hard to digest.In my case, it can look something like the following, but with the lines being way longer:
Suggested Solution
I'd like to have structures pretty-printed over multiple lines in order to make them more readable and easy troubleshooting. I can't suggest any universal pretty-printing solution for the JVM, so I'm thinking that this should be up to the user. Use
toStringby default, and let the user override with a custom printer.In Haskell Hedgehog (which I'm most familiar with), there's an alternative to
forAllcalledforAllWith, that takes a function to convert your generated value to a string. In jqwik, this is handled with method arguments and annotations, so I'm not sure what would be a suitable counterpart. Maybe there's some convention on the JVM (or in Java, specifically) that could be used?I'm leaving the solution part of this issue intentionally vague.
Discussion
Another concern, which might be a separate issue altogether, is pretty-printing in assertions. The same pretty-printing solution used for examples would be nice to use in AssertJ or whatever assertions used. Ideally, I'd like to have pretty-printed data structures and diffs (like
git diff). Example from an article I wrote:I'm not sure if there exists any library for doing pretty-printed diffs that could be used both for printing examples and in assertions.
Looking forward to getting some feedback on this!