本文介绍了无论如何我们可以使用 ShouldMatchers 在 Scalatest 中给出两个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么能做这样的事情?测试时检查两个条件
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)我想使用 ShouldMatchers 而不是 assert 来实现,因为 ShouldMatchers 是 scalatest 的一部分.
I want to do it using ShouldMatchers instead of assert, since ShouldMatchers is part of scalatest.
推荐答案你应该可以做到
val b: Option[Array[Int]] = ??? b should (be ('empty) or be (Some(Array.empty[Int]))请参阅 scalatest 手册的这一部分:逻辑表达式
See this section of the scalatest manual: Logical Expressions
更多推荐
无论如何我们可以使用 ShouldMatchers 在 Scalatest 中给出两个条件
发布评论