diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfa083d..5e9e413 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@
## Fixed
+* Reporting test cases marked with "pending" Kaocha tag as "skipped" in JUnit XML output (Issue #20)
+
## Changed
# 1.17.101 (2022-11-09 / 95067b2)
diff --git a/fixtures/kaocha-demo/demo/test.clj b/fixtures/kaocha-demo/demo/test.clj
index 30c9d00..3c5b4e0 100644
--- a/fixtures/kaocha-demo/demo/test.clj
+++ b/fixtures/kaocha-demo/demo/test.clj
@@ -22,3 +22,8 @@
(deftest ^:kaocha/skip skip-test
(println "this test does not run.")
(is false))
+
+(deftest ^:kaocha/pending pending-test
+ (println "this test does not run, but is marked as 'skipped'.")
+ (is (= {:foo 1} {:foo 1})
+ "This test would pass, if it wasn't skipped"))
diff --git a/resources/kaocha/junit_xml/JUnit.xsd b/resources/kaocha/junit_xml/JUnit.xsd
index 2460b85..37ad9f3 100644
--- a/resources/kaocha/junit_xml/JUnit.xsd
+++ b/resources/kaocha/junit_xml/JUnit.xsd
@@ -115,8 +115,13 @@ Permission to waive conditions of this license may be requested from Windy Road
+
+
+ Indicates that the test was skipped.
+
+
-
+
Name of the test method
@@ -194,6 +199,12 @@ Permission to waive conditions of this license may be requested from Windy Road
The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test.
+
+
+ The total number of tests in the suite that were skipped
+
+
+
Time taken (in seconds) to execute the tests in the suite
diff --git a/src/kaocha/plugin/junit_xml.clj b/src/kaocha/plugin/junit_xml.clj
index b29c97f..3cca4f1 100644
--- a/src/kaocha/plugin/junit_xml.clj
+++ b/src/kaocha/plugin/junit_xml.clj
@@ -45,6 +45,7 @@
start-time (:kaocha.plugin.profiling/start testable (Instant/now))]
{:errors (::result/error totals)
:failures (::result/fail totals)
+ :skipped (::result/pending totals)
:tests (::result/count totals)
:timestamp (inst->iso8601 start-time)}))
@@ -63,6 +64,9 @@
(defn classname [obj]
(.getName (class obj)))
+(defn skipped->xml [m]
+ {:tag :skipped})
+
(defn failure->xml [m]
(let [assertion-type (report/assertion-type m)]
{:tag :failure
@@ -132,6 +136,7 @@
(test-location-metadata test result)))
:content (keep (fn [m]
(cond
+ (hierarchy/pending? m) (skipped->xml m)
(hierarchy/error-type? m) (error->xml m)
(hierarchy/fail-type? m) (failure->xml m)))
events)}))
diff --git a/test/unit/kaocha/plugin/junit_xml_test.clj b/test/unit/kaocha/plugin/junit_xml_test.clj
index a22578d..1e489a2 100644
--- a/test/unit/kaocha/plugin/junit_xml_test.clj
+++ b/test/unit/kaocha/plugin/junit_xml_test.clj
@@ -30,12 +30,13 @@
(is (match?
[:testsuites
[:testsuite {:id 0
- :tests 4
+ :tests 5
:failures 1
:errors 2
:package ""
:name "unit"
:hostname "localhost"
+ :skipped 1
:timestamp string?
:time "0.000000"}
[:properties]
@@ -71,6 +72,10 @@
"│ this is on stdout\n"
"│ this is on stderr\n"
"╰─────────────────────────────────────────────────────────────────────────")]]
+ [:testcase {:name "demo.test/pending-test"
+ :classname "demo.test"
+ :time "0.000000"}
+ [:skipped]]
[:testcase {:name "demo.test/skip-test"
:classname "demo.test"
:time "0.000000"}]
@@ -91,12 +96,13 @@
(is (match?
[:testsuites
[:testsuite {:id 0
- :tests 4
+ :tests 5
:failures 1
:errors 2
:package ""
:name "unit"
:hostname "localhost"
+ :skipped 1
:timestamp string?
:time "0.000000"}
[:properties]
@@ -144,6 +150,10 @@
"│ this is on stdout\n"
"│ this is on stderr\n"
"╰─────────────────────────────────────────────────────────────────────────")]]
+ [:testcase {:name "demo.test/pending-test"
+ :classname "demo.test"
+ :time "0.000000"}
+ [:skipped]]
[:testcase {:name "demo.test/skip-test"
:classname "demo.test"
:time "0.000000"}]
@@ -164,12 +174,13 @@
(is (match?
[:testsuites
[:testsuite {:id 0
- :tests 4
+ :tests 5
:failures 1
:errors 2
:package ""
:name "unit"
:hostname "localhost"
+ :skipped 1
:timestamp string?
:time "0.000000"}
[:properties]
@@ -217,6 +228,12 @@
"│ this is on stdout\n"
"│ this is on stderr\n"
"╰─────────────────────────────────────────────────────────────────────────")]]
+ [:testcase {:name "demo.test/pending-test"
+ :classname "demo.test"
+ :time "0.000000"
+ :line 26
+ :column 1}
+ [:skipped]]
[:testcase {:name "demo.test/skip-test"
:classname "demo.test"
:time "0.000000"}]
@@ -239,7 +256,8 @@
[:testsuite {:name "my-test-type" :id 0 :hostname "localhost"
:package ""
:errors 0 :failures 1 :tests 1
- :timestamp "2007-12-03T10:15:30" :time "0.000012"}
+ :timestamp "2007-12-03T10:15:30" :time "0.000012"
+ :skipped 0}
[:properties]
[:testcase {:classname nil
:name "my-test-type"
@@ -372,7 +390,8 @@
:hostname "localhost"
:id "0"
:timestamp "2007-12-03T10:15:30"
- :failures "0"}
+ :failures "0"
+ :skipped "0"}
[:properties]
[:system-out]
[:system-err]]]