Search code examples
unit-testingclojuremidje

How to test Exception being thrown with midje


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.


Solution

  • Never mind. I found it.

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

    That works for me.