规范在 Mockito Matchers.any[FooException] 匹配器上没有失败
Spec not failing on Mockito Matchers.any[FooException] matcher
在我的规范中,我期望模拟调用 msg.ctx.failWith(any[TimeoutException])
。
因为 failWith
需要 Throwable
,所以不会检查异常的类型 - 即使在运行时也是如此。
废话过:
there was one(msg.ctx).failWith(Matchers.any[ArrayIndexOfOutBoundsException])
我可以断言传递了正确类型的异常吗?
我正在使用 Specs 2.3.13(因为它是 akka-test-kit 的依赖项)
这不是很漂亮,但它有效:
there was one(m).failWith(beLike[Throwable] { case _: TimeoutException => ok })
在我的规范中,我期望模拟调用 msg.ctx.failWith(any[TimeoutException])
。
因为 failWith
需要 Throwable
,所以不会检查异常的类型 - 即使在运行时也是如此。
废话过:
there was one(msg.ctx).failWith(Matchers.any[ArrayIndexOfOutBoundsException])
我可以断言传递了正确类型的异常吗?
我正在使用 Specs 2.3.13(因为它是 akka-test-kit 的依赖项)
这不是很漂亮,但它有效:
there was one(m).failWith(beLike[Throwable] { case _: TimeoutException => ok })