I think I'd like to be able to define test cases at run-time.

For example, I have some data files that define the tests I want to run
(tuples of [program input, class name, program output]).  I've looked at
clojure.test and midje but they only seem to have macro interfaces to their
testing engines, not functional interfaces, so I can do something like this:

(deftest functional-tests
  (testing "Test cases"
    (doseq [[input class expected-output] (read-test-cases)]
      (is (= (with-out-str
               (with-in-str input
                 (run-main class)))
             expected-output)))))

But ideally I would do something like this:

(deftest functional-tests
  (doseq [[input class expected-output] (read-test-cases)]
    (testing* (str class)
      #(is (= (with-out-str
                (with-in-str input
                  (run-main class)))
              expected-output)))))

Or the equivalent using midje instead of clojure.test

I realize the difference between the two seems small, but conceptually the
latter does more closely match what I'm doing and generates slightly more
useful output (failure names, test counts), and is only not possible
because the designers of the testing libraries didn't consider this
use-case (unless I've missed something).

Any tips?

(And wouldn't it be neat if functional versions of macros could be
automatically or almost automatically generated, so either you didn't have
to rely on library authors to consider the functional use-case, or they
were encouraged by the design of the macro system to consider it?)


Thanks,
John

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to