我正在玩 Scala 中的 BDD 的 Specs2 和 ScalaTest。当我断言不应抛出给定异常时,我在 Specs2 中写下了期望。
"do something" in {
{
....
} must not(throwA[MyException])
}
我希望能够在 ScalaTest 中编写等效的代码,例如:
"do something" in {
evaluating {
....
} should not produce[MyException]
}
但这无法编译,我找不到方法。这可能吗?
提前谢谢了。
当前版本的 ScalaTest 确实支持这一点:
noException should be thrownBy 0 / 1
See docs http://www.scalatest.org/user_guide/using_matchers#expectedExceptions.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)