我有一个返回Try对象的方法:
def doSomething(p: SomeParam): Try[Something] = {
  // code
}
Run Code Online (Sandbox Code Playgroud)
我现在想用ScalaTest测试它.目前我这样做:
"My try method" should "succeed" in {
  val maybeRes = doSomething(SomeParam("foo"))
  maybeRes.isSuccess shouldBe true
  val res = maybeRes.get
  res.bar shouldBe "moo"
}
Run Code Online (Sandbox Code Playgroud)
但是检查isSuccess是true因为选项和序列有类似的东西看起来有点笨拙should be(empty)和shouldNot be(empty).我找不到类似的东西should be(successful).
这是存在还是我的方法真的要走了?