https://kotlinlang.org logo
#strikt
Title
a

alorma

02/24/2021, 2:42 PM
Hey. looking at the errors, i thouht.... instead of show this:
Copy code
com.infojobs.app.base.datasource.cachedb.DateConverterTest > should convert Instant objects FAILED
    org.opentest4j.AssertionFailedError: ▼ Expect that 2021-02-24T14:04:22.023Z:
      ✗ is equal to 2021-02-24T14:04:22.023564Z
              found 2021-02-24T14:04:22.023Z
Wouldn't be better to show like this:
Copy code
com.infojobs.app.base.datasource.cachedb.DateConverterTest > should convert Instant objects FAILED
    org.opentest4j.AssertionFailedError:
    ▼ Expect that 2021-02-24T14:04:22.023Z:
      ✗ is equal to 2021-02-24T14:04:22.023564Z
              found 2021-02-24T14:04:22.023Z
????
I mean, move the first assertion line to the below line, to improve readability
r

robfletcher

02/24/2021, 3:52 PM
yeah, that probably would be better. Good point
c

christophsturm

02/24/2021, 5:07 PM
in failfast i just show it without the “org.opentest4j.AssertionFailedError:” part because its pretty clear that its an assertion failure
but a solution that works with all test runners would be to subclass AssertionFailedError, wit h a nicer name (maybe `strikt.Failure`` )
👍 1
a

alorma

02/24/2021, 5:09 PM
Or just add an
/n
to the start of strikt error
c

christophsturm

02/24/2021, 5:09 PM
sure, but i mean that the exception name is long and a bit useless .)
in addition to your suggestion
a

alorma

02/24/2021, 5:13 PM
Oh ok, cool
r

robfletcher

02/24/2021, 5:37 PM
yeah, I think that’s a good plan. I was intending to remove the dependency on opentest4j anyway (as it blocks any possibility of Strikt multi-platform) so creating specific Strikt exception types would make sense
c

christophsturm

02/26/2021, 3:18 PM
another thing that is a bit suprising is that the actual value is printed twice
a

alorma

02/26/2021, 4:54 PM
oh, i thought it was intended
r

robfletcher

02/26/2021, 4:55 PM
that’s really because of the
isEqualTo
being used. If you’re using another assertion, e.g.
hasLength
the assertion output wouldn’t include the actual value of the string, so it’s useful to have it in the “expect that…” part
c

christophsturm

02/26/2021, 8:18 PM
isEqual should probably omit the “found” part. Its probably the most used assertion by far
a

alorma

04/16/2021, 9:00 AM
hi... has this got merged and released?
r

robfletcher

04/16/2021, 2:09 PM
not yet. Haven’t had a lot of free time recently
c

christophsturm

04/26/2021, 7:02 AM
cool that the solution is so simple. I was going to override the exceptions with shorter names, but you can just override toString
7 Views