diff --git a/src/kaocha/type/ns.clj b/src/kaocha/type/ns.clj index 470489c9..ee2578e3 100644 --- a/src/kaocha/type/ns.clj +++ b/src/kaocha/type/ns.clj @@ -16,8 +16,10 @@ (defn run-tests [testable test-plan fixture-fn] ;; It's not guaranteed the the fixture-fn returns the result of calling the ;; tests function, so we need to put it in a box for reference. - (let [result (atom (:kaocha.test-plan/tests testable))] - (fixture-fn #(swap! result testable/run-testables test-plan)) + (let [testables (:kaocha.test-plan/tests testable) + result (atom [])] + (fixture-fn #(let [test-result (testable/run-testables testables test-plan)] + (swap! result into test-result))) @result)) (defmethod testable/-load :kaocha.type/ns [testable] diff --git a/test/unit/kaocha/fixtures_test.clj b/test/unit/kaocha/fixtures_test.clj index e486e5b7..448d5867 100644 --- a/test/unit/kaocha/fixtures_test.clj +++ b/test/unit/kaocha/fixtures_test.clj @@ -16,30 +16,50 @@ (require 'ddd.double-once-fixture-test) (let [{:keys [result report]} (with-test-ctx {:fail-fast? false} - (testable/run {:kaocha.testable/type :kaocha.type/var - :kaocha.testable/id :ddd.double-once-fixture-test/example-fail-test - :kaocha.testable/desc "example-fail-test" - :kaocha.var/name 'ddd.double-once-fixture-test/example-fail-test - :kaocha.var/var (resolve 'ddd.double-once-fixture-test/example-fail-test) - :kaocha.var/test (-> (resolve 'ddd.double-once-fixture-test/example-fail-test) meta :test)} + (testable/run (testable/load {:kaocha.testable/type :kaocha.type/ns + :kaocha.testable/id :ddd.double-once-fixture-test + :kaocha.testable/desc "ddd.double-once-fixture-test" + :kaocha.ns/name 'ddd.double-once-fixture-test}) (f/test-plan {})))] - (is (match? {:kaocha.testable/type :kaocha.type/var - :kaocha.testable/id :ddd.double-once-fixture-test/example-fail-test - :kaocha.testable/desc "example-fail-test" - :kaocha.var/name 'ddd.double-once-fixture-test/example-fail-test - :kaocha.var/var (resolve 'ddd.double-once-fixture-test/example-fail-test) - :kaocha.var/test fn? - :kaocha.result/count 1 - :kaocha.result/pass 0 - :kaocha.result/error 0 - :kaocha.result/fail 1} + (is (match? {:kaocha.testable/type :kaocha.type/ns + :kaocha.testable/id :ddd.double-once-fixture-test + :kaocha.testable/desc "ddd.double-once-fixture-test" + :kaocha.result/tests + [{:kaocha.testable/type :kaocha.type/var + :kaocha.testable/id :ddd.double-once-fixture-test/example-fail-test + :kaocha.testable/desc "example-fail-test" + :kaocha.var/name 'ddd.double-once-fixture-test/example-fail-test + :kaocha.var/var (resolve 'ddd.double-once-fixture-test/example-fail-test) + :kaocha.var/test fn? + :kaocha.result/count 1 + :kaocha.result/pass 0 + :kaocha.result/error 0 + :kaocha.result/fail 1} + {:kaocha.testable/type :kaocha.type/var + :kaocha.testable/id :ddd.double-once-fixture-test/example-fail-test + :kaocha.testable/desc "example-fail-test" + :kaocha.var/name 'ddd.double-once-fixture-test/example-fail-test + :kaocha.var/var (resolve 'ddd.double-once-fixture-test/example-fail-test) + :kaocha.var/test fn? + :kaocha.result/count 1 + :kaocha.result/pass 1 + :kaocha.result/error 0 + :kaocha.result/fail 0}]} result)) - (is (match? [{:type :begin-test-var} - {:type :pass + (is (match? [{:type :begin-test-ns} + {:type :begin-test-var} + {:type :fail :expected '(= 1 2) :actual '(not (= 1 2)) :message nil} - {:type :end-test-var}] - report))))) + {:type :end-test-var} + {:type :begin-test-var} + {:type :pass + :expected '(= 2 2) + :actual '(= 2 2) + :message nil} + {:type :end-test-var} + {:type :end-test-ns}] + (mapv #(select-keys % [:type :expected :actual :message]) report))))))