Victor Basso
Victor Basso

Reputation: 5796

Clojure (deps.edn) separate integration tests

How do you configure deps.edn so you run integration tests separately from unit tests?

I have the following project tree:

.
├── deps.edn
├── src
│       (...)
├── test
│   └── package
│       └── test.clj
└── it
    └── package
        └── integration_test.clj

Desired behavior:

clj -Atest #runs unit tests only
clj -Ait   #runs integration tests only

Attempted configuration:

{:deps    (...)}
 :aliases {:test {:extra-paths ["test"]
                  :extra-deps  {lambdaisland/kaocha {:mvn/version "0.0-529"}}
                  :main-opts   ["-m" "kaocha.runner"]}
           :it {:extra-paths ["it"]
                :extra-deps  {lambdaisland/kaocha {:mvn/version "0.0-529"}}
                :main-opts   ["-m" "kaocha.runner"]}}}

Actual behavior:

clj -Atest #runs unit tests only
clj -Ait   #runs unit tests only

Upvotes: 2

Views: 276

Answers (1)

Victor Basso
Victor Basso

Reputation: 5796

We need to add a tests.edn file:

#kaocha/v1
{:tests [{:id          :unit
          :test-paths  ["test"]
          :ns-patterns [".*"]}
         {:id          :integration
          :test-paths  ["it"]
          :ns-patterns [".*"]}]}

And add references to the test ids defined above to deps.edn:

{:deps    (...)}
 :aliases {:test {:extra-paths ["test"]
                  :extra-deps  {lambdaisland/kaocha {:mvn/version "0.0-529"}}
                  :main-opts   ["-m" "kaocha.runner" "unit"]}
           :it {:extra-paths ["it"]
                :extra-deps  {lambdaisland/kaocha {:mvn/version "0.0-529"}}
                :main-opts   ["-m" "kaocha.runner" "integration"]}}}

Source: lambdaisland/kaocha

Upvotes: 2

Related Questions