Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions fixtures/kaocha-demo/demo/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
13 changes: 12 additions & 1 deletion resources/kaocha/junit_xml/JUnit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ Permission to waive conditions of this license may be requested from Windy Road
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="skipped">
<xs:annotation>
<xs:documentation xml:lang="en">Indicates that the test was skipped.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:attribute name="name" type="xs:token" use="required">
<xs:attribute name="name" type="xs:token">
<xs:annotation>
<xs:documentation xml:lang="en">Name of the test method</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -194,6 +199,12 @@ Permission to waive conditions of this license may be requested from Windy Road
<xs:documentation xml:lang="en">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.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="skipped" type="xs:int">
<xs:annotation>
<xs:documentation xml:lang="en">The total number of tests in the suite that were skipped</xs:documentation>
</xs:annotation>
</xs:attribute>

<xs:attribute name="time" type="xs:decimal" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">Time taken (in seconds) to execute the tests in the suite</xs:documentation>
Expand Down
5 changes: 5 additions & 0 deletions src/kaocha/plugin/junit_xml.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)}))

Expand All @@ -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
Expand Down Expand Up @@ -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)}))
Expand Down
29 changes: 24 additions & 5 deletions test/unit/kaocha/plugin/junit_xml_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"}]
Expand All @@ -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]
Expand Down Expand Up @@ -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"}]
Expand All @@ -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]
Expand Down Expand Up @@ -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"}]
Expand All @@ -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"
Expand Down Expand Up @@ -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]]]
Expand Down