Unit testing Emacs Lisp code with ElUnit

ElUnit is a unit test framework for Emacs Lisp. You can define your test suites and see how they run against your code. It’s a great toolkit for test-driven development in Emacs Lisp as well. Running your tests manually after each changes may make you bored, though. Fortunately, you are using an extensible editor. In my scenario, I taught Emacs to automatically run corresponding test suites whenever I save the file I’m editing. As for the file topology, I put my tests under sub-directory tests/, and call them in scheme my-file-test.el. On the very beginning of each code file, I place a magic comment to specify file variable elunit-default-suite that holds the name of the test suite I want to run.

;; -*- elunit-default-suite: "my-demo-suite" -*-

The following snippet does the rest of the job: my_elunit.el