How to test Exception being thrown with midje

587 Views Asked by At

Simple question. I'm trying to test in midje if my method triggers an exception. I could only find something like the following in the midje documentation.

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

Thanks.

1

There are 1 best solutions below

0
Neikon On BEST ANSWER

Never mind. I found it.

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

That works for me.