3

我正在尝试以交互方式运行 Emacs ert 测试,但它没有运行。我正在按照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。

4

1 回答 1

4

要运行测试用例,您必须首先通过加载文件或评估缓冲区来定义它。该ert命令不会自动执行此操作。

当然,您可以轻松定义自己的函数来评估当前缓冲区并运行ert.

于 2016-03-17T10:13:32.437 回答