I want to store my tests as data so i can pass them around to a couple different places. I imagine something like:
[{:fn 'foo :input [0] :output 0}
{:fn 'foo :input [1] :output 1}]
However, most testing frameworks, notable clojure.test, likely for good reasons, use macros, so it's obvious to me how to do this. I was going to look around at some other frameworks and how they did things...macros don't preclude you using variable input data. you could say
(deftest example-test
(doseq [{:keys [f inputs output]} tests]
(is (= output (apply f inputs)))))
and that would work just finegood point
clojure.test-compatible libraries use metadata on symbols, so if you can turn your data into an anonymous fn, you can programmatically attach it as :test metadata to a var.
Thanks sean. Why does it need to be an anonymous fn? Whats an example of a clojure.test-comptabible library? my googling found expectations and rfc.
Well, it doesn't need to be anonymous but it's just a function value and it's attached to the original symbol as :test metadata.
Did you mean RCF rather than RFC? I wouldn't really call that clojure.test-compatible since it doesn't create statically-predictable named tests.
expectations.clojure.test is clojure.test-compatible by design (the "classic" Expectations library is not, nor is Midje). Don't confuse that with test runners.