my dog learned polymorphism
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
JavaRanch » Java Forums » Languages » Clojure
Bookmark "Extending clojure unit tests " Watch "Extending clojure unit tests " New topic

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: 283

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:

You can generate JUnit-compatible output (in theory) using the lein-test-out plugin: (caveat: I have not had much success integrating this with ant yet).
I agree. Here's the link:
subject: Extending clojure unit tests
It's not a secret anymore!