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

后端 未结 4 480
野的像风
野的像风 2021-02-05 07:29

Is there a way to truncate the test results to only show result text for unit tests only when the unit test has failed? I\'m working on a Scala project that has 850 unit tests,

4条回答
  •  清酒与你
    2021-02-05 07:59

    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.

提交回复
热议问题