无论如何我们可以使用 ShouldMatchers 在 Scalatest 中给出两个条件

Is there anyway we can give two conditions in Scalatest using ShouldMatchers

我怎样才能做这样的事情?测试时检查两个条件

// b is Option[Array[Int]]
b should be ('empty) || b.get should be ('empty)

我想使用 ShouldMatchers 而不是 assert 来完成它,因为 ShouldMatchers 是 scalatest 的一部分。

你应该可以做到

val b: Option[Array[Int]] = ???
b should (be ('empty) or be (Some(Array.empty[Int]))

请参阅最新手册的这一部分:Logical Expressions