Skip to content

Commit 6442679

Browse files
authored
Merge pull request #294 from lambdaisland/alys/fix-no-test-message
Fix "no tests" message
2 parents 5b81078 + d144fbc commit 6442679

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/kaocha/api.clj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,19 @@
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 (format (str "All %d tests were skipped."
108+
" Check for misspelled settings in your Kaocha test configuration"
109+
" or incorrect focus or skip filters.")
110+
(count (testable/test-seq-with-skipped test-plan))))
111+
(output/warn (str "No tests were found. This may be an issue in your Kaocha test configuration."
112+
" To investigate, check the :test-paths and :ns-patterns keys in tests.edn.")))
107113
(throw+ {:kaocha/early-exit 0 }))
114+
108115
(when (find-ns 'matcher-combinators.core)
109116
(require 'kaocha.matcher-combinators))
110117

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)