8

With the junit-interface runner, there was this handy option:

-q Suppress stdout for successful tests. Stderr is printed to the console normally. Stdout is written to a buffer and discarded when a test succeeds. If it fails, the buffer is dumped to the console. Since stdio redirection in Java is a bad kludge (System.setOut() changes the static final field System.out through native code) this may not work for all scenarios. Scala has its own console with a sane redirection feature. If Scala is detected on the class path, junit-interface tries to reroute scala.Console's stdout, too.

I was wondering whether there was an easy way to make scalatest do the same thing. I can try to redirect the output myself but would prefer to use something standard if possible.

Mysterious Dan
  • 1,316
  • 10
  • 25

2 Answers2

0

According to this info on the ScalaTest website, you can set some flags to suppress some messages:

If you add a line like this in your build.sbt, your logger will not show successful tests in the stdout:

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

xeroqu
  • 425
  • 5
  • 14
0

Actually that is a question that was asked on github, at the scalatest repository. You can find it here.

As suggeted there, you can add -oNCXEHLOPQRM to the running options. It means that in your sbt you need to add:

testOptions in Test += Tests.Argument("-oNCXEHLOPQRM")

That alone will might be sufficient, as sbt itself logs its own startup, and that all tests passed. If you want to get ONLY the failed tests, you can add the -error flag to the sbt command, and then it will skip the info log level.

In such case, when all tests passes the output will be completely empty. An example to such a command will be:

sbt test -error

If you want to further read about the scala test configuration report, you can do it here. They have plenty of options.

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35