Formatting output so that Intellij Idea shows diffs for two texts

后端 未结 2 1233
暖寄归人
暖寄归人 2021-02-04 02:09

I would like to be able to print in the logs a message for which intellij idea would present a nice way of comparing two objects (strings). This happens automatically for the er

相关标签:
2条回答
  • 2021-02-04 02:21

    IntelliJ IDEA is using the hardcoded regular expression. If the text matches the pattern, it will suggest to click to view the difference.

    The pattern is:

    expected:<bla-blah> but was:<blah-blah-blah>
    

    Output should match the format of assertEquals or assertThat.

    The exact patterns are somewhat scattered around the code in IDEA, but some are e.g. here.

    0 讨论(0)
  • 2021-02-04 02:38

    I had the same Problem and found the solution in https://github.com/joel-costigliola/assertj-core/issues/1364#issuecomment-440800958

    You should throw an org.junit.ComparisonFailure. Then IntelliJ will display the <Click to see difference>

    0 讨论(0)
提交回复
热议问题