exunit.el
exunit.el copied to clipboard
Emacs ExUnit test runner
#+TITLE: exunit
[[https://melpa.org/#/exunit][https://melpa.org/packages/exunit-badge.svg]]
Provides commands to run [[https://hexdocs.pm/ex_unit/ExUnit.html][ExUnit]] tests. The output is syntax highlighted and stacktraces are navigatable.
- Setup
exunit is available in [[https://melpa.org/#/exunit][melpa]] and can be installed via package-install command.
#+begin_src emacs-lisp (add-hook 'elixir-mode-hook 'exunit-mode)
;; Optionally configure transient-default-level' to 5 to show extra switches ;; Or use C-x l' to change the level of individual commands and switches
(setq transient-default-level 5) ;; default is 4
#+end_src
Currently, 2 extra switches are shown, =--exclude= and =--include=.
- Commands
| Keyboard | Description | |-------------+---------------------------------------------------------------------------------------------------------------| | =C-c , a= | exunit-verify-all Run all the tests in the current project | | =C-c , u= | exunit-verify-all-in-umbrella Run all the tests in the current umbrella project | | =C-c , v= | exunit-verify Run all the tests in the current buffer, or the test file corresponding to the current buffer | | =C-c , s= | exunit-verify-single Run the test under the point | | =C-c , r= | exunit-rerun Re-run the last test invocation | | =C-c , t= | exunit-toggle-file-and-test Toggle between a file and its tests in the current window | | =C-c , d= | exunit-debug Run the test under the point in IEx shell. Supports IEx.pry method for debugging. | | =C-c , 4 t= | exunit-toggle-file-and-test-other-window Toggle between a file and its tests in other window |
Invoking any of these commands with a prefix argument =C-u= will cause a prompt to be shown for additional arguments before the test(s) are run.
[[https://raw.githubusercontent.com/ananthakumaran/exunit.el/master/screenshots/sample.png]]
- Run tests in a docker
For example, you can redefine an =exunit-mix-command= to the following to execute in =backend= service context:
#+begin_src emacs-lisp (setq exunit-mix-command (lambda (args) (let* ((args (s-join " " args)) (mix-command (concat "'mix test " args "'"))) ;; Adjust to your needs (list "docker-compose" "exec" "backend" "sh" "-c" mix-command)))) #+end_src