I'm trying to run an Emacs ert test interactively, but it doesn't run. I'm following the Emacs ERT guide to run this example test:
(require 'ert)
(ert-deftest pp-test-quote ()
"Tests the rendering of `quote' symbols in `pp-to-string'."
(should (equal (pp-to-string '(quote quote)) "'quote"))
(should (equal (pp-to-string '((quote a) (quote b))) "('a 'b)\n"))
(should (equal (pp-to-string '('a 'b)) "('a 'b)\n")))
Executing this test from the buffer with M-x ert RET t RET will output:
Selector: t
Passed: 0
Failed: 0
Skipped: 0
Total: 0/0
Started at: 2016-03-16 21:15:10+0100
Finished.
Finished at: 2016-03-16 21:15:10+0100
But it works if is executed from the console (in batch mode):
$ emacs -batch -l ert -l test.el -f ert-run-tests-batch-and-exit
Running 1 tests (2016-03-16 21:35:26+0100)
passed 1/1 pp-test-quote
Ran 1 tests, 1 results as expected (2016-03-16 21:35:26+0100)
I'm using emacs 24.5.
To run a test case, you must first define it, either by loading the file or by evaluating the buffer. The ert
command does not do this automatically.
Of course, you can easily define your own function that evaluates the current buffer and runs ert
.