Hot answers tagged

6

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.


5

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.


5

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))) ...)


4

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'...


3

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 ...


3

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) (run-hooks 'pre-command-hook) (command-execute cmd) (run-hooks 'post-command-hook) ...


3

Assuming rspec: Install rspec-mode, which will activate itself automatically in ruby-mode or enh-ruby-mode then you can use C-c,s to run rspec-verify-single which will run the test at point.


2

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 (...


2

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 http://cider.readthedocs.org/en/latest/extended_workflow/#running-tests


2

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." (skip-unless (ert-test-passed-p (ert-test-most-recent-result (ert-get-test 'vc-test-git00-...


2

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.


2

I've used the following construct: (defvar objc-font-lock-test-setup-directory (if load-file-name (file-name-directory load-file-name) default-directory)) It works both when the file is loaded or when doing something like an eval-buffer.


2

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 () (ert-skip "pending") (should (dostuff)))


2

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."


2

(void-function loop) 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.


1

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.


1

One way is by string comparisons, e.g. (require 'ert) (ert-deftest test-1 () (should (string= (with-temp-buffer (org-mode) (insert " * test heading ") (goto-char (point-min)) (promote-next-heading) (buffer-string)) " ** test heading "))) You could also have content in files and do it like this: (ert-deftest ...


1

Outside of Cider, there is toggle-test, which can switch between source and test buffers in a language agnostic way.


1

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.


1

Maybe something like this: (defun func-one () (message "running: func-one") nil) (defun func-two () (message "running: func-two") (and (func-one) t)) (defun func-thr () (message "running: func three") (or (func-one) t)) (require 'ert) (ert-delete-all-tests) (setq func-tests nil) (ert-deftest test-one () "Test basic functionality" (when (...


1

This way it works: (defun get-current-test-name () (save-excursion (let ((pos) (test-name)) (re-search-backward "test \"\\([^\"]+\\)\" do") (setq test-name (buffer-substring-no-properties (match-beginning 1) (match-end 1))) (concat "test_" (replace-regexp-in-string " " "_" test-name))))) (defun run-test-at-point () (...


1

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).


Only top voted, non community-wiki answers of a minimum length are eligible