https://kotlinlang.org logo
Join SlackCommunities
Powered by
# hamkrest
  • d

    dmcg

    02/05/2019, 9:30 AM
    set the channel description: Discussion about the Hamkrest test assertions library
  • d

    dmcg

    02/05/2019, 9:32 AM
    Is there any Hamkrest mode where it can report multiple failure when matching
    &&
    expressions? I'm trying to migrate some code and only see the first problem in matches like
    Copy code
    java.lang.AssertionError: expected: a value that is not null & has address line 1 that is equal (ignoring case) to null and has address line 2 that is equal (ignoring case) to null and has address line 3 that is equal (ignoring case) to null and has alternative first name that is equal (ignoring case) to "Katsuhiro" and has alternative first name 2 that is equal to "カツヒロ" and has alternative last name that is equal (ignoring case) to "Otomo" and has alternative last name 2 that is equal to "オトモ" and has apps opt in that is equal to false and has city that is equal (ignoring case) to null and has country iso 3 that is equal to null and has creation store id that is equal to "DC00" and has date of birth that is equal to null and has email that is equal to null and has email opt in that is equal to false and has first name that is equal (ignoring case) to "克洋" and has id that is not null and has language id that is equal to null and has last name that is equal (ignoring case) to "大友" and has mobile phone that is equal to null and has nationality iso 3 that is equal to null and has phone that is equal to null and has phone opt in that is equal to false and has post opt in that is equal to false and has raw cegid data that is not null & anything or null and has region id that is equal to null and has sales person id that is equal to null and has signature date time that is equal to null and has title id that is equal to null and has wechat id that is equal to null and has zip code that is equal to null
    but had alternative first name 2 that was: "オトモ"
  • n

    natpryce

    02/05/2019, 9:40 AM
    Agreed. Hamkrest error messages can balloon to unhelpful size, and the logical operators do not create very good messages
  • n

    natpryce

    02/05/2019, 9:41 AM
    I’m currently working on improvements to hamkrest to allow better error messages, and allow client code (eg assertions) to simplify logical expressions
  • n

    natpryce

    02/05/2019, 9:42 AM
    And also making it multiplatform
  • n

    natpryce

    02/05/2019, 9:48 AM
    I’m thinking that matchers should report mismatches as structured data, and then client code (eg assertion function or test framework) translate that into a human readable representation.
  • d

    dmcg

    02/05/2019, 9:54 AM
    That's a nice approach - a failure with two lumps of JSON that IntelliJ could present side by side would do here
  • n

    natpryce

    02/07/2019, 5:23 PM
    A multiplatform version of hamkrest will have to wait until Kotlin 1.3.30
  • n

    natpryce

    02/07/2019, 5:24 PM
    (It crashes the native compiler)
  • n

    natpryce

    02/07/2019, 5:24 PM
    But until then I’ll have a think about reporting mismatches
  • d

    dmcg

    02/13/2019, 10:29 AM
    This https://www.reddit.com/r/Kotlin/comments/apip8o/i_wrote_a_library_for_pretty_printing_objects/ might come in handy
  • n

    natpryce

    02/14/2019, 3:42 PM
    Hello.
  • n

    natpryce

    02/22/2019, 12:42 PM
    The plans for the next version of Hamkrest are: * build and distribute as a multiplatform library * structured mismatch reporting for better diagnostics This will break backward compatibility, so that lets us also... * modernise the API, using language features introduced since it was first published
  • n

    natpryce

    02/22/2019, 12:43 PM
    Multiplatform support is well underway. Master passes its tests on the JVM, JS and native platforms.
  • n

    natpryce

    02/22/2019, 12:44 PM
    Many thanks to everyone on the #multiplatform channel who helped
  • d

    dmcg

    03/25/2020, 12:03 PM
    Thought that these might come in handy for anyone using Hamkrest and Result4K https://gist.github.com/dmcg/dff9e38adeda2fc3c3d39b156f4dde63
  • n

    natpryce

    03/25/2020, 12:07 PM
    Very nice
  • d

    dmcg

    03/25/2020, 12:10 PM
    I take it you mean the name rather than the code 😉
  • g

    gypsydave5

    07/05/2023, 4:17 PM
    did hamkrest ever get a nice way to integrate with the Intellij diff for test output?