我正在尝试以交互方式运行Emacs ert测试,但它没有运行。 我正在关注运行此示例测试:
(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")))
使用 M-x ert RET t RET 从缓冲区执行此测试将输出:
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
但是如果从控制台执行(在批处理模式下),它可以工作:
$ 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)
我正在使用emacs 24.5。
答案 0 :(得分:3)
要运行测试用例,必须先通过加载文件或评估缓冲区来定义它。 ert
命令不会自动执行此操作。
当然,您可以轻松定义自己的函数来评估当前缓冲区并运行ert
。