Hey Chris,
Thanks for the quick response. I took a look at the link you posted. The syntax I used was most heavily influenced by that in lisp-unit because
what any given function or macro did was very clear from the name without having to read the documentation first. Names like ASSERT-TRUE
and ASSERT-EQUAL are pretty self explanatory! Also the syntax is very simple and easy to read and use.
Because the syntax is so close to that of lisp-unit I will make a quick translation with a few changes and test it. The changes would be as shown below,
the rest is pretty much the same.(in-package :cs325-user)
;;; Define a suite for all our tests since CLUnit only groups according to test suites instead of the implicit package grouping in lisp-unit.
(defsuite cs325-user ())
(define-test testname . body) -> (deftest testname (cs325-user) . body)
I had left out ASSERT-PRINTS simply because I had not considered its uses well enough. But after you pointed it out, I realised having a built in form
to test the messages you print in your library would be very handy.
The definition of ASSERT-TRUE that I used is actually a predicate tester according to its common use in Lisp conditional
forms such as IF and WHEN. I figured if you want to test for the specific value T you would use (assert-eq t form).
(assert-equality 'set-equal '(car) (functions-referenced '(car l))) -> (assert-true (set-equal '(car) (functions-referenced '(car l)))
There is an idea I have been toying with in my head. It seems the library generally works now so I think its now
safe to write unit tests for the library itself. Now, I obviously need test the lower level functions and make
sure that they are doing the correct thing. So I have a situation were I want to test A and B, but since B depends
of A, if A fails its test there is no point testing B. I would need to first fix A before I can trust what B will do.
Basically, I want to be able to short circuit tests. I want to add this without changing the current behaviour.
Since execution of tests in a test suite is unordered, you would place the dependent tests in a child test suite.
So something like this:
1. (defsuite A ())
2. (defsuite B (A))
3. Define low level function tests in A.
4. Define tests in B that depend on functions tested in A.
5. (run-suite 'A :stop-on-fail t)
The RUN-SUITE keyword argument :use-debugger, is for interactive tests, this option would work for short circuiting batch tests.
What do you think?