Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure.test and Leinigen: How to run just a single test from command line

this:

Run one Clojure test (not all tests in a namespace), with fixtures, from the REPL

works fine with repl, how can I do this from command line using Leinigen?

like image 608
Tomas Kulich Avatar asked Jan 05 '17 12:01

Tomas Kulich


People also ask

How do you run a Clojure test?

You can run tests by using the cljs. test/run-tests macro. This may be done in your REPL or at the end of your file. If you have many test namespaces it's idiomatic to create a test runner namespace which imports all of your test namespaces and then invokes run-tests .

What is lein test?

lein test provides the ability to run all tests in a project. lein test <selector> <selector-args> allows a custom selector to be defined by a project's project. clj file in the :test-selectors key. A selector is a function that can look at a namespace or a test var and decide whether a test should run or not.


1 Answers

What you are looking for is probably:

lein test :only my.namespace/my-test 

Note that:

lein help test 

outputs:

"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." 
like image 154
Mike Avatar answered Sep 18 '22 17:09

Mike