leiningen

zendevil.eth 2022-01-03T19:52:19.048100Z

is there a way to impose order on the test namespaces that are run with lein test?

2022-01-03T21:50:41.049200Z

Not that I am aware of. I think people using clojure.test typically make any ordering constraints on order of steps, e.g. setup, do-thing1, do-thing2, do-thing3, teardown, all within a single test, never between differently named tests.

2022-01-03T21:51:55.049400Z

clojure.test does have a mechanism to call a function before each test is run, and/or when a test is finished.

2022-01-03T21:54:57.049600Z

Here is one example I did of defining a clojure.test :begin-test-var and :end-test-var : https://github.com/clojure/core.rrb-vector/blob/master/src/test/clojure/clojure/core/rrb_vector/test_utils.clj#L52-L64

zendevil.eth 2022-01-03T20:02:03.048800Z

also is there a way to run a specific function before all tests are run, not before the tests in the namespace?

zendevil.eth 2022-01-04T10:08:31.051100Z

How to use test-ns with lein test?

zendevil.eth 2022-01-04T10:08:58.051900Z

Lein test simply runs all tests in all namespaces recursively in the given directory

zendevil.eth 2022-01-04T15:10:20.052100Z

note that I mean run a function before all tests are run in all ns with lein test

2022-01-04T16:02:25.053700Z

Did you see my replies to your previous message? There is a link to an example of how to do that if you are using clojure.test

zendevil.eth 2022-01-04T16:09:07.053900Z

Let’s say I create this:

(defmethod test/migrations :begin-test-var [m]
    (user/start)
    (user/reset-db))
Where do I put this in my lein project and how to call it before lein test?

zendevil.eth 2022-01-04T16:18:20.054200Z

I’m not making myself clear

zendevil.eth 2022-01-04T16:19:14.054400Z

I mean this: 1. run fn-1 and fn-2 2. Run all tests in all namespaces NOT 1. Run fn-1 Run fn-2 2. Run test 1 3. Run fn-1 Run fn-2 4. Run test 2 …

2022-01-04T16:23:29.054700Z

I do not know of a way built into clojure.test to do that

2022-01-04T16:23:48.054900Z

except to change how you structure your tests in your namespaces, so there is only one deftest

2022-01-04T16:24:32.055100Z

but I'm not necessarily the most expert on clojure.test capabilities, either.

2022-01-04T02:49:45.050100Z

You can look into test ns hooks.

2022-01-04T02:49:56.050600Z

Which is actually a feature of clojure.test I believe.