如何测试用 midje 抛出的异常

How to test Exception being thrown with midje

简单的问题。如果我的方法触发异常,我正在尝试在 midje 中进行测试。我只能在 midje 文档中找到类似以下内容。

(fact "Should throw a RuntimeException"
               (my-method! anything) =throws=> (RuntimeException.)

谢谢。

没关系。我找到了。

(fact "Should throw a RuntimeException"
           (my-method! anything) => (throws RuntimeException)

这对我有用。