-
Notifications
You must be signed in to change notification settings - Fork 83
/
history.clj
37 lines (31 loc) · 1.14 KB
/
history.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(ns kaocha.history
(:require [clojure.test :as t]
[kaocha.hierarchy :as hierarchy]))
(def ^:dynamic *history* nil)
(defmulti track :type :hierarchy #'hierarchy/hierarchy)
(defmethod track :default [m] (swap! *history* conj m))
(defmethod track :kaocha/fail-type [m]
(swap! *history* conj (assoc m
:testing-contexts t/*testing-contexts*
:testing-vars t/*testing-vars*)) )
(defmethod track :error [m]
(swap! *history* conj (assoc m
:testing-contexts t/*testing-contexts*
:testing-vars t/*testing-vars*)))
(defn clojure-test-summary
([]
(clojure-test-summary @*history*))
([history]
(reduce
(fn [m {type :type :as event}]
(cond
(some #{type} [:pass :error :kaocha/pending]) (update m type inc)
(hierarchy/isa? type :kaocha/begin-test) (update m :test inc)
(hierarchy/fail-type? event) (update m :fail inc)
:else m))
{:type :summary
:test 0
:pass 0
:fail 0
:error 0}
history)))