/
xfail.clj
31 lines (27 loc) · 1.02 KB
/
xfail.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
(ns kaocha.plugin.alpha.xfail
"This plugin inverses fail & pass for tests marked with the ^:kaocha/xfail
metadata. A failing test can be marked with this metadata, and will now be
considered passing. Once the test passes again, it fails.
Note that this current implementation inverses each assertion in turn, so if
you have multiple assertions in a xfail test, then they all must fail for the
test to pass."
(:require [kaocha.plugin :as plugin]
[kaocha.testable :as testable]
[kaocha.hierarchy :as hierarchy]))
(plugin/defplugin kaocha.plugin.alpha/xfail
(post-load [test-plan]
(update
test-plan
:kaocha/reporter
(fn [reporter]
(fn [event]
(reporter
(if (-> event :kaocha/testable ::testable/meta :kaocha/xfail)
(cond
(hierarchy/fail-type? event)
(assoc event :type :pass)
(= (:type event) :pass)
(assoc event :type :fail)
:else
event)
event)))))))