scala - 如果失败,如何仅显示 Scalatest 测试的标准输出

标签 scala scalatest

junit-interface运行者,有这个方便的选择:

-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.



我想知道是否有一种简单的方法可以让 scalatest 做同样的事情。我可以尝试自己重定向输出,但如果可能的话,我更愿意使用标准的东西。

最佳答案

根据这个info在 ScalaTest 网站上,您可以设置一些标志来抑制某些消息:

如果您在 build.sbt 中添加这样的行,您的记录器将不会在标准输出中显示成功的测试:
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oN")

关于scala - 如果失败,如何仅显示 Scalatest 测试的标准输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18063412/

相关文章:

递归打印方法中的数组

scala - 了解 NotUsed 和 Done

scala - 如何在 phantom dsl 中对枚举类型进行建模?

scala - 如何使用 ScalaTest 编写验收测试?

scala - 简洁但可扩展的 Scala/sbt 测试以验证 Project Euler 答案

scala - 在 Play Framework 2.4.2 中使用 scalates/specs2 测试 HttpErrorHandler

design-patterns - Scala 程序员 - "should there be one obvious way to do it"还是 "more than one way to do it"?

java - 如何mock scala val 提交?

Scalatrasuite 测试总是在 sbt 中失败,在 IDE 中运行测试时成功

Scalatest 异步测试套件与最终和WhenReady (org.scalatest.concurrent)