leiningen

jcd 2025-01-14T01:14:32.632799Z

Is there a simple way to make lein run specific tests (or groups of tests) alone, during a run that runs all tests?

2025-01-14T08:58:08.926549Z

usually you annotate some tests with metadata and use a test selector for them - See: https://codeberg.org/leiningen/leiningen/src/branch/main/sample.project.clj#L368-L370

2025-01-14T08:58:55.543699Z

$ lein help test
Run the project's tests.

Marking deftest or ns forms with metadata allows you to pick selectors to
specify a subset of your test suite to run:

    (deftest ^:integration network-heavy-test
      (is (= [1 2 3] (:numbers (network-operation)))))

Write the selectors in project.clj:

    :test-selectors {:default (complement :integration)
                     :integration :integration}

Arguments to this task will be considered test selectors if they are keywords,
otherwise arguments must be test namespaces or files to run. With no
arguments the :default test selector is used if present, otherwise all
tests are run. Test selector arguments must come after the list of namespaces.

A default :only test-selector is available to run select tests. For example,
`lein test :only leiningen.test.test/test-default-selector` only runs the
specified test. A default :all test-selector is available to run all tests.

If :eval-in :nrepl is specified in the project, test namespaces may reload
out-of-order. However, all test namespaces will be (re)loaded at least
once (in *some* order).

This task uses the following exit codes:
- 0 if all tests pass successfully
- 1 otherwise

Arguments: ([& tests])

jcd 2025-01-14T12:06:45.984429Z

Thank you! That’s what I ended up doing.