在scalatest中,如何在测试结果中显示完整的差异?

tri*_*oid 8 unit-testing scala scalatest

当 scalatest 中的相等断言失败时。它通常只显示不同的部分,例如:

"...error;
!I e: F[Arg]
[g invalid because
nonconformant bounds;
[Arg, Nothing]
[A <: __wrapper$1$47213a912399466a973eddce7b3420f4.__wrapper$1$47213a912399466a973eddce7b3420f4.]Bounds.Base, B]
  im..." did not equal "...error;
!I e: F[Arg]
[Bounds.g invalid because
nonconformant bounds;
[Arg, Nothing]
[A <: ]Bounds.Base, B]
  im..."
org.scalatest.exceptions.TestFailedException: "...error;
!I e: F[Arg]
[g invalid because
nonconformant bounds;
[Arg, Nothing]
[A <: __wrapper$1$47213a912399466a973eddce7b3420f4.__wrapper$1$47213a912399466a973eddce7b3420f4.]Bounds.Base, B]
  im..." did not equal "...error;
!I e: F[Arg]
[Bounds.g invalid because
nonconformant bounds;
[Arg, Nothing]
[A <: ]Bounds.Base, B]
  im..."
Run Code Online (Sandbox Code Playgroud)

这份报告中丢失了很多信息。另外,当IDE配备diff解析器时,它会错误地显示比较结果。有没有办法在scalatest中禁用此功能,这样报告中就不会出现任何省略号?

小智 0

您可以添加标志-- -Dtest.show_diff=true。完整的命令如下所示:test-only *TestFileName* -- -Dtest.show_diff=true