Fork me on GitHub
#leiningen
<
2017-08-03
>
xiongtx00:08:06

Do Lein test selectors have access to other test selectors? Or only to test metadata? I happen to several different classes of tests (e.g. ^:app-1 and ^:app-2), as well as a differentiation between types of tests (`^:integration` vs. not). The following seems a bit repetitive:

:test-selectors {:app-1-unit #(and (:app-1 %)
                                   (not (:integration %)))
                 :app-1-integration #(and (:app-1 %)
                                          (:integration %))
                 :app-1 :app-1

                 :app-2-unit #(and (:app-2 %)
                                   (not (:integration %)))
                 ...}
Seems like it’d be more composable if test selectors can refer to each other.

Shantanu Kumar05:08:30

Hi, can anybody share a tip on how to execute some project initialization code when I run lein test? I need to load some config and initialize state before running tests but only once for the project, not in every test namespace. Does Leiningen have any hooks for this?

xiongtx17:08:58

Environment variables can be set with environ and its Lein plugin, lein-environ: https://github.com/weavejester/environ You can then have a config.edn file in the project that references those environment variables. I also like aero for auto type casting and composing values: https://github.com/juxt/aero

Shantanu Kumar04:08:59

Thanks, but I am actually looking for a way to NOT put the initialization trigger in every test namespace, but rather as a Leiningen hook or something

Shantanu Kumar04:08:26

I already have the config/init stuff sorted, I just need to decouple that from every test namespace