Meaningless Drivel is fun!*
The moose likes Clojure and the fly likes Extending clojure unit tests Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Languages » Clojure
Bookmark "Extending clojure unit tests " Watch "Extending clojure unit tests " New topic
Author

Extending clojure unit tests

jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Hi guys (btw thanks shawn for keeping the clojure thread alive !!!) :

I'm totally new to macros and extending clojure, so concrete examples would really help :

My problem : I have 3 types of unit tests - fail, succeed, and warning. However, default Leiningan test only seems to have 2 outputs : failures, and successes.
My happiness : I noted that the clojure.test package has a great API, and is really modular. Thus, I know my problem has a solution !
My new problem : How can I extend my unit tests to have 3 result types, and how can I integrate these result types with my build ?

In particular I want to know

1) How is success/failure defined/determined by clojure.test and how is this communicated to external programs (i.e. like jenkins) which automate clojure builds ??? We are planning on automating our builds, and I need to know how clojure conveys success/failure (for that matter, I don't even know how ANT defines/conveys success/failure, and I use ANT every day, so I have a long way to go as a build engineer) .

2) How can I define a "third" test result for tests that don't pass, but dont fail either (for example, in PHP, you can "skip" a unit test)??? I assume clojure might offer a flexible way of defining new test outputs. In particular I found a success? function uses a map.... But its not quite clear how it is used or extended to me.

Thanks !!!

Sean Corfield
Ranch Hand

Joined: Feb 09, 2011
Posts: 259
    
    5

From an automated build's point of view there are only successful tests and failing tests. There's no third state. I'm not sure what you're trying to achieve there?

For skipping tests, look at Leiningen's test selectors, described here: https://groups.google.com/group/leiningen/browse_thread/thread/e421df80db71b2ce

You can generate JUnit-compatible output (in theory) using the lein-test-out plugin: https://github.com/arohner/lein-test-out (caveat: I have not had much success integrating this with ant yet).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Extending clojure unit tests