quicktheories / QuickTheories

Property based testing for Java 8
Apache License 2.0
505 stars 51 forks source link

error reporting when using checkAssert #40

Open danwallach opened 6 years ago

danwallach commented 6 years ago

I've got a number of QuickTheories tests using JUnit5's assertions and the checkAssert() feature. When you combine this with IntelliJ, here's a sample of the error output that appears when comparing the lengths of two lists that are supposed to be the same but there was a bug that made them differ:

screen shot 2018-02-28 at 9 59 03 am

If you hit "click to see the difference", you'd expect to see something like <0> versus <1>. Instead, you see this:

screen shot 2018-02-28 at 9 59 52 am

I don't have a specific idea in mind for how to fix this. Some possibilities include:

danwallach commented 6 years ago

One other possibility: in JUnit5, they added the concept of a TestFactory --- a method that returns Iterable<DynamicTest> where a DynamicTest is a string (name of the test) plus a lambda that is executed, and which might or might not have a failed assertion within.

It would be modestly clever to be able to write something like

@TestFactory
public Iterable<DynamicTest> testWhatever() {
    return qtFactory().forAll(...).checkAssert(...);
}