Skip to content

Running unit tests in Ciderλ︎

SPC p a switches between source and test buffers.

, t n run all tests in the current namespace. This also loads any changes to those tests.

, t a run all tests. If tests are changed or added, , e f to evaluate those tests to add them to the REPL or , e b on any test buffers that have changed.

The results of running the tests are displayed in the mini-buffer, showing the number of tests run and how many passed and failed.

Spacemacs Cider tests - results in mini-buffer

Hint::Spacemacs loads current buffer before running testsλ︎

Run unit tests from the buffer that has changes or new tests. Otherwise, ensure all buffers with changes have been evaluated to ensure the tests run with the right src and test code.

Using Test Selectors to run specific testsλ︎

Using the universal argument before calling CIDER test runner will prompt for test selector filters, running only those tests that match the selector inclusions/exclusions.

SPC t a runs all the tests in a project.

SPC u SPC t a prompts for test selectors and runs the matching tests in a project.

SPC t l runs all tests currently evaluated in the REPL.

SPC u SPC t l prompts for test selectors and runs the matching tests currently evaluated in the REPL.

CIDER first prompts for the test selectors to include:

Spacemacs Clojure Cider Test Runner test selector prompt - include

Then prompts for the test selectors to exclude. A warning displays in the power line if CIDER does not find the test selector name.

Spacemacs Clojure Cider Test Runner test selector prompt - include

Running tests in the REPL bufferλ︎

, to open the REPL command menu and select run tests

Auto Unit Test Modeλ︎

, T t to toggle auto test mode

, e b will evaluate the current buffer and automatically run all tests.

Hint::CIDER test report only created on test failureλ︎

To show a test report each time tests are run, add the variable cider-test-show-report-on-success t in the clojure layer list of the .spacemacs file.

     (clojure :variables
              cider-test-show-report-on-success t)