I want this test to run with every lein test
:
(ns acker.core-test
(:require [clojure.test :refer :all]
According to Making Leiningen work for You by Phil Hagelberg, the test-selectors
feature was added to Leiningen in version 1.4.
Two easy steps. First, add this to project.clj
:
:test-selectors {:default (complement :slow)
:slow :slow
:all (constantly true)}
Second, mark up your test with metadata:
(deftest ^:slow ackermann-slow-test
(testing "ackermann (slow)"
(are [m n e] (= (ack-3 m n) e)
3 3 61
3 4 125
4 0 13
4 1 65533)))
Now you have three options for running your tests:
⚡ lein test
⚡ lein test :slow
⚡ lein test :all
Also, this information is easy to find with lein test -h
:
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 :all (constantly true)}
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.Arguments: ([& tests])