Questions tagged [ert]

ERT is a tool for automated testing in Emacs Lisp. Its main features are facilities for defining tests, running them and reporting the results, and for debugging test failures interactively.

23 questions
7
votes
2 answers

run a single ERT test programmatically

I'm trying to write a piece of code that runs a single ERT test programmatically. In the ERT manual, they show an example that creates a test body and then runs the body, like so: (ert-deftest ert-test-record-backtrace () (let ((test…
Kevin
  • 1,308
  • 8
  • 20
4
votes
1 answer

How can I test an idle timer with ERT?

Say I have a function that is called on an idle timer: (defun tmp:create () (mkdir "test")) (run-with-idle-time 3 nil #'tmp:create) How can I test that this function works? Using something like (ert-deftest async () "" (should-not (file-exists-p…
Sean Allred
  • 6,861
  • 16
  • 85
4
votes
4 answers

writing tests for a post-self-insert-command hook

I wrote a minor mode with the purpose of modifying written text on the fly. It is currently creating a post-self-insert-command-hook, and triggers only on specific keypresses (e.g. the space bar, a semicolon, an open parens). As an example, the user…
Trevoke
  • 2,375
  • 21
  • 34
4
votes
1 answer

Stop ERT results frame from stealing focus

I've set up ert test results to display in a separate frame, if one exists, and in a bottom side-window otherwise: (add-to-list 'display-buffer-alist '("\\`\\*ert\\*\\'" (display-buffer-reuse-window …
ivan
  • 1,928
  • 10
  • 20
4
votes
2 answers

Where should my ERT tests go?

I'm new to using ERT for testing my Elisp code, and I have a question that doesn't seem to be covered in the manual: according to best practices, where does one typically put the ERT tests? Do they go at the end of the elisp file that is to be…
Ryan C. Thompson
  • 435
  • 2
  • 10
3
votes
1 answer

What is ERT for?

I'm still a little confused about ERT. Is it for running regression tests of your elisp code or for running regression tests of other code too? For example would I run my JUnit tests under ERT, and ERT would display the results, jump to the…
JasonN
  • 139
  • 3
2
votes
2 answers

How can I skip a test if another test failed?

Say I have two tests: (defun func-one () nil) (defun func-two () (and (func-one) t)) (ert-deftest test-one () "Test basic functionality" (should (func-one))) (ert-deftest test-two () "Test advanced functionality" (should (func-two))) How…
Sean Allred
  • 6,861
  • 16
  • 85
2
votes
1 answer

How to run "ert" tests?

What I tried: Cloned a package with ert tests (https://github.com/dgutov/robe ) # sidenote this package was previously installed using use-package emacs ~/robe/core-tests.el M-x ert Selector: t Passed: 0 Failed: 0 Skipped: 0 Total: 0/0 Started…
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
2
votes
1 answer

Accessing resource files in ERT tests

I'm trying to use ERT to test the ycmd package, and part of what I need to do is pass bodies of code to the ycmd server and ask for completion candidates. I'd like to be able to keep these bodies of code in separate files, partly for organization…
abingham
  • 927
  • 6
  • 18
2
votes
1 answer

Why does this function stub not work using cl-letf?

I have written this simple function and I want to stub out the last functions so I don't actually launch a process. (defun dc-test-stub-process (command &rest params) (interactive) (let ((commands (append (list dc-buffer-name dc-docker-cmd…
Oly
  • 583
  • 1
  • 5
  • 15
2
votes
2 answers

Pending test in Ert

I'm currently starting to build a package the TDD way, and for that I'm using ert, following ert-runner opinions. I would like to write a set of pending tests, to identify what I have I to test, before to implement the test. Is it possible to write…
AdrieanKhisbe
  • 209
  • 1
  • 10
1
vote
0 answers

How to impose a timeout on ert tests?

When using ert I'd sometimes like to have tests abort after some timeout. I could program this in advance in the test-case but this is not what I need. Imagine a situation where I use ert-run-tests-batch for non-regression testing after I modified…
phs
  • 1,095
  • 6
  • 13
1
vote
1 answer

Enforce order of ERT tests?

When running ert tests, the seem to be run by default in string< order. For instance running tests (require 'ert) (ert-deftest t1111 () (print 'AAAA)) (ert-deftest t3333 () (print 'BBBB)) (ert-deftest t2222 () (print 'CCCC)) (ert-run-tests-batch…
kdb
  • 1,561
  • 12
  • 21
1
vote
1 answer

Why is check-ert output cut at 70 characters column?

Sometimes when packaging emacs packages for Debian, I need to debug test failures. Then the debugging output is cut at 70 characters like in this bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916807#21 excerpt: Test…
Thomas Koch
  • 173
  • 2
1
vote
1 answer

Using equal-including-properties to compare # string and propertized string

I'm writing some tests for my first emacs package but am running into an issue to do with asserting that two text properties are the same - one that's created with # and another with propertize: ;; this fails (ert-deftest equal-properties () …
xdl
  • 125
  • 3
1
2