How to configure sbt test / ScalaTest to only show failures?

喜你入骨 提交于 2019-12-03 01:31:06

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

There is also a "drop TestSucceeded events" flag, but I have failed to use it: http://www.scalatest.org/user_guide/using_the_runner

For those using maven with the scalatest-maven-plugin, you can add this configuration:

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

Updated answer for Scalatest 3.

Here's the new syntax for your build.sbt file to reprint all the failures at the bottom of the test suite run:

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oI")

You might also want to suppress the info notifications, so it's easier to see the failures.

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oNCXELOPQRM")

Here's what all the options represent:

  • N - drop TestStarting events
  • C - drop TestSucceeded events
  • X - drop TestIgnored events
  • E - drop TestPending events
  • H - drop SuiteStarting events
  • L - drop SuiteCompleted events
  • O - drop InfoProvided events
  • P - drop ScopeOpened events
  • Q - drop ScopeClosed events
  • R - drop ScopePending events
  • M - drop MarkupProvided events

"-oI" prints the error notifications again at the end of the test suite run whereas "-oNCXELOPQRM" only shows the tests that fail.

See the configuring reporters section on the ScalaTest website for more detail.

You could try the sbt command

last-grep error test

This should show you the errors/failures only.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!