如何配置 sbt test/ScalaTest 只显示失败? [英] How to configure sbt test / ScalaTest to only show failures?
问题描述
有没有办法截断测试结果,仅在单元测试失败时才显示单元测试的结果文本?我正在处理一个包含 850 个单元测试的 Scala 项目,而成功的单元测试中的绿色文本让我很难只关注失败的部分.
Is there a way to truncate the test results to only show result text for unit tests only when the unit test has failed? I'm working on a Scala project that has 850 unit tests, and the green text from the successful unit tests makes it difficult to focus on just the failures.
我正在谈论的示例:
[info] - should have colors
[info] - should not be dead
//.... x 100
[info] - animals should not be rainbows *** FAILED ***
[info] -"[rainbow]s" was not equal to "[ponie]s" (HappinessSpec.scala:31)
我想要的是只显示失败的东西:
What I would like is something that just shows the failure(s):
[info] - animals should not be rainbows *** FAILED ***
[info] -"[rainbow]s" was not equal to "[ponie]s" (HappinessSpec.scala:31)
我意识到有 test-quick
sbt 命令,但它仍然运行 300 成功在我的案例中只有 30 次失败时进行单元测试.
I realize there is the test-quick
sbt command, but it's still running 300 successful
unit tests in my case when there are only 30 failures.
在使用方面与此类似的东西正是我正在寻找的:
Something along the lines of this in terms of usage is what I'm looking for:
sbt>~ 测试 -showOnlyFailures
我也很高兴能在运行结束时显示所有失败单元测试.IIRC,这就是 RSpec 在 Ruby 中的工作方式...
I would also be happy with something that shows all of the failures at the end of running the unit tests. IIRC, this is how RSpec works in Ruby...
推荐答案
在 build.sbt 添加以下内容后,scalaTest 会在标准报告后显示失败摘要:
After adding the following to build.sbt, scalaTest will show a fail summary after the standart report:
testOptions in Test += Tests.Argument("-oI")
I - show reminder of failed and canceled tests without stack traces
T - show reminder of failed and canceled tests with short stack traces
G - show reminder of failed and canceled tests with full stack traces
还有一个drop TestSucceeded events"标志,但是我没用过:http://www.scalatest.org/user_guide/using_the_runner
There is also a "drop TestSucceeded events" flag, but I have failed to use it: http://www.scalatest.org/user_guide/using_the_runner
这篇关于如何配置 sbt test/ScalaTest 只显示失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!