Clojure (deps.edn) 单独的集成测试
Clojure (deps.edn) separate integration tests
如何配置 deps.edn
以便 运行 将集成测试与单元测试分开?
我有以下项目树:
.
├── deps.edn
├── src
│ (...)
├── test
│ └── package
│ └── test.clj
└── it
└── package
└── integration_test.clj
期望的行为:
clj -Atest #runs unit tests only
clj -Ait #runs integration tests only
尝试的配置:
{: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"]}}}
实际行为:
clj -Atest #runs unit tests only
clj -Ait #runs unit tests only
我们需要添加一个 tests.edn
文件:
#kaocha/v1
{:tests [{:id :unit
:test-paths ["test"]
:ns-patterns [".*"]}
{:id :integration
:test-paths ["it"]
:ns-patterns [".*"]}]}
并将对上面定义的测试 ID 的引用添加到 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"]}}}
如何配置 deps.edn
以便 运行 将集成测试与单元测试分开?
我有以下项目树:
.
├── deps.edn
├── src
│ (...)
├── test
│ └── package
│ └── test.clj
└── it
└── package
└── integration_test.clj
期望的行为:
clj -Atest #runs unit tests only
clj -Ait #runs integration tests only
尝试的配置:
{: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"]}}}
实际行为:
clj -Atest #runs unit tests only
clj -Ait #runs unit tests only
我们需要添加一个 tests.edn
文件:
#kaocha/v1
{:tests [{:id :unit
:test-paths ["test"]
:ns-patterns [".*"]}
{:id :integration
:test-paths ["it"]
:ns-patterns [".*"]}]}
并将对上面定义的测试 ID 的引用添加到 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"]}}}