testingclojuremidje

How to skip Clojure Midje tests


If I have a Clojure test suite written using the Midje testing framework, how do I skip individual tests? For example, if I were using JUnit in Java and I wished to skip a single test, I would add an @Ignore attribute above that test method. Is there an equivalent to this for Midje?

I realise that I could add a label to my test metadata and then run the test suite excluding that label. For example, if I labelled my test with ":dontrun", I could then run the test suite with "lein midje :filter -dontrun". This would involve a change to my Continuous Integration task that runs the test suite though, and I'd prefer not to do this. Is there an equivalent test label of JUnit's @Ignore so that I only need to change the Midje test code and not change my Continuous Integration task?


Solution

  • future-fact does what you want, just substitute (or wrap) your fact with it:

    (future-fact "an interesting sum"
       (sum-up 1 2) => 4)
    

    This will, instead of executing the test code, print a message during the test run:

    WORK TO DO "an interesting sum" at (some_tests.clj:23)