6

yes, elunit 1.0!

 3 years ago
source link: https://technomancy.us/59
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Has it really almost been a week? Well, it's been a good week for hacks.

ElUnit 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 defsuite macro:

(defsuite my-test-suite
  (two-plus-two
    "Test that 2 + 2 = 4"
    (assert (equal 4 (+ 2 2))))

  (another-test
    (assert (equal 0 (- 2 2))))

  (bad-math
    "This test should fail!"
    (assert (equal 5 (+ 2 2))))

  (another-test
    "duplicate should overwrite original"
    (assert (equal 3 (length (elunit-suite 'my-test-suite))))))

(add-hook 'my-test-suite-teardown-hook (lambda () (message "teardown hook")))

M-x elunit gets you some nicely formatted reports:

Loaded suite:  my-test-suite

.F.

1) Failure:  bad-math [/home/phil/.emacs.d/elunit-test.el: 13]
            This test should fail!
    Result:  (cl-assertion-failed (equal 5 (+ 2 2)))


3 tests total,  1 failures in 0 seconds.

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 the wiki discussion.

Grab it straight out of my Trac.

« older | 2006-08-23T12:17:40Z | newer »

All posts | Résumé | Projects | Talks | Colophon | Technomancy is © 2004 – 2020 Phil Hagelberg


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK