问题
How can I do something like this? Check for two conditions while testing
// b is Option[Array[Int]]
b should be ('empty) || b.get should be ('empty)
I want to do it using ShouldMatchers instead of assert, since ShouldMatchers is part of scalatest.
回答1:
You should be able to do
val b: Option[Array[Int]] = ???
b should (be ('empty) or be (Some(Array.empty[Int]))
See this section of the scalatest manual: Logical Expressions
来源:https://stackoverflow.com/questions/27964790/is-there-anyway-we-can-give-two-conditions-in-scalatest-using-shouldmatchers