Skip to content

Commit b875e2c

Browse files
committed
Add new warning for skipped tests when no tests are found.
Checks whether any tests were skipped before printing message about load errors.
1 parent 5b81078 commit b875e2c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/kaocha/api.clj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,20 @@
9999
(with-bindings (config/binding-map config)
100100
(let [config (resolve-reporter config)]
101101
(let [test-plan (test-plan config)]
102+
102103
(when-not (some #(or (hierarchy/leaf? %)
103104
(::testable/load-error %))
104105
(testable/test-seq test-plan))
105-
(output/warn (str "No tests were found, make sure :test-paths and "
106-
":ns-patterns are configured correctly in tests.edn."))
106+
(if (not (zero? (count (filter ::testable/skip (testable/test-seq-with-skipped test-plan)))))
107+
(output/warn (str "No tests were found and some tests were"
108+
" skipped; check for misspelled settings"
109+
" or combinations of settings that no tests"
110+
" satisfy."))
111+
(output/warn (str "No tests were found. This may be an issue in your test configuration."
112+
" To investigate, check the :test-paths and :ns-patterns keys in tests.edn."))
113+
)
107114
(throw+ {:kaocha/early-exit 0 }))
115+
108116
(when (find-ns 'matcher-combinators.core)
109117
(require 'kaocha.matcher-combinators))
110118

src/kaocha/testable.clj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,16 @@
235235
;; the outer map. When running on an actual testable, do include it.
236236
(:kaocha.testable/id testable)
237237
(cons testable)))
238+
239+
(defn test-seq-with-skipped
240+
[testable]
241+
"Create a seq of all tests, including any skipped tests.
242+
243+
Typically you want to look at `test-seq` instead."
244+
(cond->> (mapcat test-seq (or (:kaocha/tests testable)
245+
(:kaocha.test-plan/tests testable)
246+
(:kaocha.result/tests testable)))
247+
;; When calling test-seq on the top level test-plan/result, don't include
248+
;; the outer map. When running on an actual testable, do include it.
249+
(:kaocha.testable/id testable)
250+
(cons testable)))

0 commit comments

Comments
 (0)