Femtounit, a unit test framework for Interlisp
I wanted a small framework simple to port to or write for Interlisp, yet useful in practice. At less than a couple dozen lines of code, Femtounit took very little effort to design and write as it's based on the PCL test framework Peter Seibel described in Chapter 9 of his book Practical Common Lisp.
I reused much of Peter's design and code, adapting it to Interlisp and tweaking the reporting of tests. Femtounit outputs a single period character for every passed test, unlike the full report his framework prints.
Using Femtounit looks like this:
Suppose you want to test this function that returns the square of its argument:
(DEFINEQ (SQUARE (X) (TIMES X X)))
You may define a
TEST.SQUARE test function like this:
(DEFTEST TEST.SQUARE () (CHECK.EXPECT (EQP (SQUARE 1) 1) (EQP (SQUARE 2) 4) (EQP (SQUARE 3) 9) (EQP (SQUARE 4) 16)))
To run the tests, just call the function:
which will print a period character for every passed test:
Some documentation is at the project repo.
After I finished the initial code of Femtounit, Larry Masinter pointed out Medley does have a test framework, and quite an advanced one. This system, which the Medley documentation simply calls test system and is much more than a framework, was originally designed to test Interlisp and its environment. The code is now in one of the Medley repos.
I thought I explored every nook and cranny of Medley and its documentation, yet I missed the test system. The system is interesting in itself and I'll use it for most of my code.
But Femtounit is a fun little learning project I still want to proceed with. It'll teach me how to integrate the framework with Interlisp for editing unit test definitions with the SEdit structure editor, as well as saving the definitions to files and managing them with the
make-like File Manager tool.