如何配置sbt测试/ ScalaTest只显示失败?

是否有一种方法可以截断测试结果,仅在单元测试失败时才显示单元测试的结果文本? 我正在开发一个拥有850个单元测试的Scala项目,而成功的单元测试中的绿色文本使得难以专注于失败。

我在说什么的例子:

[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)

我想要的是只显示失败的事情:

[info] - animals should not be rainbows *** FAILED *** 
[info] -"[rainbow]s" was not equal to "[ponie]s" (HappinessSpec.scala:31)

我意识到有test-quick sbt命令,但在我的情况下,它仍然运行300次成功的单元测试,只有30次失败。

根据使用情况,这是我正在寻找的东西:

sbt> ~ test -showOnlyFailures

在运行单元测试结束时,我也会对某些显示所有失败的东西感到满意。 IIRC,这是RSpec如何在Ruby中工作的...


将以下内容添加到build.sbt后,scalaTest将在标准报告之后显示失败摘要:

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

还有一个“下降TestSucceeded事件”标志,但我没有使用它:http://www.scalatest.org/user_guide/using_the_runner


对于那些使用maven和scalatest-maven插件的人,你可以添加这个配置:

<configuration>
  <stdout>I</stdout>
</configuration>

你可以试试sbt命令

last-grep error test

这应该只显示错误/失败。

链接地址: http://www.djcxy.com/p/42573.html

上一篇: How to configure sbt test / ScalaTest to only show failures?

下一篇: how to set main class in SBT 0.13 project