Idle timers won't be touched until the call stack has been cleared, so sitting won't actually help, it is only once all execution has stopped with the timer be run, so in your case, the idle timer won't run until 3 seconds of idle time after your whole test has run.
To combat this, you can call ert-run-idle-timers from ert-x.el in your test.
Both macros are lexically scoped, that's why they have no effect on the "distant" call. Either use the deprecated older flet or cl-letf.
(cl-letf (((symbol-function 'return-number)
(lambda () 2)))
I think that there are only the following solutions:
Run tests outside of Emacs from your terminal emulator
Run tests from realgud
Run tests inside Emacs via eshell. But shell output may be corrupted, so this not a good solution
Run tests with pytest-el. It works good, but without autocompletion.
It's not specifically for "pending", but marking the test as expected to fail seems like it would be what you want: http://www.gnu.org/software/emacs/manual/html_node/ert/Expected-Failures.html
add `:expected-result :failed' to the test definition:
(ert-deftest future-bug ()
"Test `time-forward' with negative arguments.
Since this functionality isn'...
A wild guess: put the file name in a defvar or a defconst, and use it in the function:
(defconst my-test-location (file-name-directory (or load-file-name buffer-file-name)))
(ert-deftest closing-braces ()
(find-file (concat my-test-location "ClosingBrace.file")))
What you want is the value of load-file-name or buffer-file-name at compile/load time, but ...
I don't think there's a very satisfactory answer, but here's what I used today for testing the new undo-redo command I installed into master:
(defun simple-tests--exec (cmds)
(dolist (cmd cmds)
(setq last-command this-command)
(setq this-command cmd)
When a file is loaded, load-file-name is set. When a form is evaluated interactively from a file, buffer-file-name is set. So you can use (or load-file-name buffer-file-name) as the value of a global variable. You can then use file-name-directory and such to get parent directories.
If you use the f.el file name library, you can use something like (f-parent (...
there is an option to run all the tests in all the projects namespaces
M-x cider-test-run-project-tests or C-c C-t C-p
Here is the link to additional options for running tests
I have used something like this in vc-tests.el:
(ert-deftest vc-test-git00-create-repo ()
"Check `vc-create-repo' for the git backend."
(ert-deftest vc-test-git01-register ()
"Check `vc-register' and `vc-registered' for the git backend."
I recommend Projectile for this, and much more, project-related functionality. Projectile has a binding C-c p t (projectile-toggle-between-implementation-and-test) that offers exactly what you're looking for.
I've used the following construct:
It works both when the file is loaded or when doing something like an eval-buffer.
Placing a call to ert-skip at the beginning of your test would be the solution I believe. If you'd like, you can pass the string "pending" to the function to better show why it was skipped.
(ert-deftest my-pending-test ()
Projectile provides a projectile-toggle-between-implementation-and-test function with exactly this behavior. As stated in the docs, you can use C-c p t to "Toggle between an implementation file and its test file."
loop is not available, which comes from cl.el. In your code/tests, you should load this library before using loop. When you launch Emacs interactively with your own init.el, it is usually already loaded since it is a common library used by many other packages.
One idea might be to save a copy of the current buffer, run the tests, and then run a diff command on them.
(defun run-tests ()
(copy-to-buffer "*my-test*" (point-min) (point-max))
(diff-buffers "*my-test*" (current-buffer)))
This will make a new buffer showing the diff (if any). There are ...
This is expected behavior, but you can circumvent this problem by let-binding executing-kbd-macro to t, which will convince the minibuffer commands to read from unread-command-events rather than from stdin.
One way is by string comparisons, e.g.
(ert-deftest test-1 ()
* test heading
** test heading
You could also have content in files and do it like this:
Traceback highlighting is provided by the compile package.
You can use M-x compile to run a script and get traceback highlighting. If you have an existing buffer with a traceback, you can use M-x compilation-minor-mode to highlight the tracebacks there.
Unfortunately there is not a way to do this currently in cider.
One would have to write a custom command to evaluate clojure.tests/run-all-tests (or clojure.tests/run-tests with a list of namespaces as arguments).