<commit_before>#+TITLE: Running tests

Elisp tests are run using [[http://www.emacswiki.org/emacs/ErtTestLibrary][ERT]], an Emacs Lisp library for regression/unit
testing. Tests can be run several ways:

1. Interactively, with =M-x ert RET test-name=
2. From the terminal, in batch mode, with ~emacs -batch -l ert -l my-test.el -f
   ert-run-tests-batch-and-exit~
3. Other options can be found in the docs, =C-h i m ert RET=

Interactive testing is great while you're working on an exercise, but batch mode
testing is preferable for when you want to check that an exercise is ready for
submission. The above command is a bit unwieldy, so if you like:

1. Create a file on your ~$PATH~ (probably in =~/bin=) called =ert-run=
2. The contents of the file should be as follows:
   #+BEGIN_SRC sh
   #!/usr/bin/sh
   emacs -batch -l ert -l $1 -f ert-run-tests-batch-and-exit
   #+END_SRC
3. Make the file executable with ~chmod +x ert-run~

You should be able to simply call ~ert-run exercise-test.el~ and run the tests
in batch mode.

*** Working on exercises
Since Emacs is, itself, an elisp interpreter, your working code is always in its
native execution environment. You an evaluate any form by pressing =C-x e= at
the end of the form, or a selection with =M-x eval-region= or the whole buffer
with =M-x eval-buffer=. This can be extremely useful for quickly debugging your
code.

*** Suggestions
Since both your code and tests are valid elisp, it is suggested to work with
your exercise code in a buffer pane side-by side with its test, like so:

#+HTML: <img src="/img/setup/emacs/dual-pane.png">

Split the frame vertically with =C-x 3=, and open the file with =C-x C-f
/path/to/file=.
<commit_msg>Update image path in documentation<commit_after>#+TITLE: Running tests

Elisp tests are run using [[http://www.emacswiki.org/emacs/ErtTestLibrary][ERT]], an Emacs Lisp library for regression/unit
testing. Tests can be run several ways:

1. Interactively, with =M-x ert RET test-name=
2. From the terminal, in batch mode, with ~emacs -batch -l ert -l my-test.el -f
   ert-run-tests-batch-and-exit~
3. Other options can be found in the docs, =C-h i m ert RET=

Interactive testing is great while you're working on an exercise, but batch mode
testing is preferable for when you want to check that an exercise is ready for
submission. The above command is a bit unwieldy, so if you like:

1. Create a file on your ~$PATH~ (probably in =~/bin=) called =ert-run=
2. The contents of the file should be as follows:
   #+BEGIN_SRC sh
   #!/usr/bin/sh
   emacs -batch -l ert -l $1 -f ert-run-tests-batch-and-exit
   #+END_SRC
3. Make the file executable with ~chmod +x ert-run~

You should be able to simply call ~ert-run exercise-test.el~ and run the tests
in batch mode.

*** Working on exercises
Since Emacs is, itself, an elisp interpreter, your working code is always in its
native execution environment. You an evaluate any form by pressing =C-x e= at
the end of the form, or a selection with =M-x eval-region= or the whole buffer
with =M-x eval-buffer=. This can be extremely useful for quickly debugging your
code.

*** Suggestions
Since both your code and tests are valid elisp, it is suggested to work with
your exercise code in a buffer pane side-by side with its test, like so:

#+HTML: <img src="http://x.exercism.io/v3/tracks/elisp/docs/img/dual-pane.png">

Split the frame vertically with =C-x 3=, and open the file with =C-x C-f
/path/to/file=.

{'fraction_non_alphanumeric': 0.09125144843568946, 'fraction_numerical': 0.004924681344148319, 'mean_word_length': 3.7236662106703147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2587396', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1085, 'n_words': 532}