specs2: How to use “failtrace” option

杀马特。学长 韩版系。学妹 提交于 2019-12-10 15:04:04

问题


In my specs2 tests, I frequently use helper functions to test groups of conditions at once. Unfortunately, that makes the line number output of failed tests useless, since all failures are on the same line.

Google turned up that there's a "failtrace" option that will output the stack trace of failure. However, I can't find an example of how to actually use that. Is it in build.sbt? Is it used on the SBT command line? Is it set somehow in the constructor of the Specification class?


回答1:


You can set the failtrace option at the specification level:

class MySpec extends org.specs2.mutable.Specification {
  args.report(failtrace = true)
  ...
}

You can also pass failtrace on the sbt command line:

sbt> test-only *MySpec* -- failtrace



回答2:


Eric's solution can also be applied to all tests run by SBT by including the following in your build.sbt file:

testOptions += Tests.Argument(TestFrameworks.Specs2, "failtrace")


来源:https://stackoverflow.com/questions/23114020/specs2-how-to-use-failtrace-option

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