如何让intellij在失败的测试中提供文本差异比较

Bru*_*owe 13 scala intellij-idea scalatest intellij-14

我正在用一些ScalaTest匹配器编写Scala测试.

当我的测试失败时,intellij说了类似的话

{"count":3,"pagination":{"offset":0,"limit":100},"content":{"uri":"http://locahost.com/catalogue/content?order=Query&id=18,20,19"},"list":[{"id":"18","position":27},{"id":"20","position":341},{"id":"19","position":33}]} was not equal to {"count":3,"pagination":{"offset":0,"limit":100},"content":{"uri":"http://locahost.com/catalogue/content?order=Query&id=18,20,19"},"list":[{"id":"18","timestamp":"2015-01-28T11:55:44.494Z","content":"Episode","position":27},{"id":"20","timestamp":"2015-01-19T11:55:44.494Z","content":"Program","position":341},{"id":"19","timestamp":"2015-01-17T11:55:44.494Z","content":"Episode","position":33}]}
org.scalatest.exceptions.TestFailedException: {"count":3,"pagination":{"offset":0,"limit":100},"content":{"uri":"http://locahost.com/catalogue/content?order=Query&id=18,20,19"},"list":[{"id":"18","position":27},{"id":"20","position":341},{"id":"19","position":33}]} was not equal to {"count":3,"pagination":{"offset":0,"limit":100},"content":{"uri":"http://locahost.com/catalogue/content?order=Query&id=18,20,19"},"list":[{"id":"18","timestamp":"2015-01-28T11:55:44.494Z","content":"Episode","position":27},{"id":"20","timestamp":"2015-01-19T11:55:44.494Z","content":"Program","position":341},{"id":"19","timestamp":"2015-01-17T11:55:44.494Z","content":"Episode","position":33}]}
at    org.scalatest.MatchersHelper$.newTestFailedException(MatchersHelper.scala:160)
at org.scalatest.Matchers$ShouldMethodHelper$.shouldMatcher(Matchers.scala:6231)
at org.scalatest.Matchers$AnyShouldWrapper.should(Matchers.scala:6265)
...
Run Code Online (Sandbox Code Playgroud)

然而,intellij并没有给我方便的看法文字功能的区别.

我想这可能是因为我正在比较2个物体

  val responseBody = responseAs[JsValue]
  responseBody should be(viewingByAccountIdResponseJson)
Run Code Online (Sandbox Code Playgroud)

但改变它

assert(responseBody.toString() === viewingByAccountIdResponseJson.toString())
Run Code Online (Sandbox Code Playgroud)

不允许我进行文本比较.

有没有办法配置intellij来做到这一点?

(我目前正在使用带有Matchers的FlatSpec)

注意:这与此问题格式化输出有关, 因此Intellij Idea显示两个文本的差异

但是,即使使用intellij可能会提到的语法,它也不起作用.

Bru*_*owe 5

我认为目前这是不可能的,截至当前时刻,是一个功能请求:

https://youtrack.jetbrains.com/issue/SCL-4867