当我使用sbt运行以下简单测试时,我得到了我期望的输出:
import org.scalatest.{FlatSpec, Matchers, Suites}
class TestSimple extends FlatSpec with Matchers {
"a" should "do" in {
Array(1,3) should equal (Array(1,2))
}
}
输出:
[info] TestSimple:
[info] a
[info] - should do *** FAILED ***
[info] Array(1, 3) did not equal Array(1, 2) (SimpleTest.scala:5)
[info] ScalaTest
[info] Run completed in 980 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0
[info] *** 1 TEST FAILED ***
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error] TestSimple
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful
当测试包含在套件中并使用DoNotDiscover进行注释时,如下所示:
import org.scalatest.{DoNotDiscover, FlatSpec, Matchers, Suites}
class FullTestSuite extends Suites(new TestSimple)
@DoNotDiscover
class TestSimple extends FlatSpec with Matchers {
"a" should "do" in {
Array(1,3) should equal (Array(1,2))
}
}
然后输出不包括每个测试成功和失败,而是仅包含整体结果:
[info] ScalaTest
[info] Run completed in 975 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 2, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0
[info] *** 1 TEST FAILED ***
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error] FullTestSuite
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful
如何在Suite实例中运行测试以输出它们失败的位置和方式?
由于