Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (47 sloc) 2.2 KB
timestamp: 2006-08-23 12:17:40
title: yes, elunit 1.0!
tags: projects, emacs
id: 59
content: |
<p>Has it really almost been a week? Well, it's been a good week for
<p><a href=''>ElUnit</a> is
a unit testing framework for Emacs Lisp designed to allow
Test-Driven development. I believe it to be pretty much at release
quality, though a few more convenience macros (assert-equal, for
instance) remain to be written. You define suites of tests using
the <code>defsuite</code> macro: </p>
<pre class='code'>
(defsuite <span class="keyword">my-test-suite</span>
<span class="string">"Test that 2 + 2 = 4"</span>
(<span class="warning">assert</span> (equal 4 (+ 2 2))))
(<span class="warning">assert</span> (equal 0 (- 2 2))))
<span class="string">"This test should fail!"</span>
(<span class="warning">assert</span> (equal 5 (+ 2 2))))
<span class="string">"duplicate should overwrite original"</span>
(<span class="warning">assert</span> (equal 3 (length (elunit-suite 'my-test-suite))))))
(add-hook 'my-test-suite-teardown-hook (<span class="keyword">lambda</span> () (message <span class="string">"teardown hook"</span>)))
<p><kbd>M-x elunit</kbd> gets you some nicely formatted reports: </p>
<pre class='code'>
Loaded suite: my-test-suite
.<span style='color: red;'>F</span>.
1) Failure: bad-math [<u>/home/phil/.emacs.d/elunit-test.el: 13</u>]
This test should fail!
Result: (cl-assertion-failed (equal 5 (+ 2 2)))
3 tests total, 1 failures in 0 seconds.
<p>How many times do I have to tell you that two plus two is four?
Anyway, I'm pretty happy with the results, especially considering I
was able to keep it at about 90 LOC. Give it a shot, and if you've
got anything to say, pipe up
on <a href=''>the wiki
it</a> straight out of my Trac.</p>
Jump to Line
Something went wrong with that request. Please try again.