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

Run tests from test code buffer

Run tests from the buffer containing the test source code buffer, as this ensures all test code is loaded and the latest version of the tests are run.

Tests can be run from the source code buffer, however, only test code that has been evaluated in the REPL will run.

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

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
              clojure-enable-linters 'clj-kondo
              cider-test-show-report-on-success t)

results matching ""

    No results matching ""