Liking cljdoc? Tell your friends :D

lambdaisland/kaocha-junit-xml

CircleCI cljdoc badge Clojars Project codecov

Kaocha plugin to generate a JUnit XML version of the test results.

Usage

  • Add kaocha-junit-xml as a dependency
;; deps.edn
{:aliases
 {:test
  {:extra-deps {lambdaisland/kaocha {...}
                lambdaisland/kaocha-junit-xml {:mvn/version "0.0-63"}}}}}

or

;; project.clj
(defproject ,,,
  :dependencies [,,,
                 [lambdaisland/kaocha-junit-xml "0.0-63"]])
  • Enable the plugin and set an output file
;; tests.edn
#kaocha/v1
{:plugins [:kaocha.plugin/junit-xml]
 :kaocha.plugin.junit-xml/target-file "junit.xml"}

Or from the CLI

bin/kaocha --plugin kaocha.plugin/junit-xml --junit-xml-file junit.xml

Requirements

Requires at least Kaocha 0.0-306 and Clojure 1.9.

CircleCI

One of the services that can use this output is CircleCI. Your .circleci/config.yml could look like this:

version: 2
jobs:
  build:
    docker:
      - image: circleci/clojure:tools-deps-1.9.0.394
    steps:
      - checkout
      - run: mkdir -p test-results/kaocha
      - run: bin/kaocha --plugin kaocha.plugin/junit-xml --junit-xml-file test-results/kaocha/results.xml
      - store_test_results:
          path: test-results

Caveats

For timing information (timestamp and running time) this plugin relies on the kaocha.plugin/profiling plugin. If the plugin is not present then a running time of 0 will be reported.

For output capturing the kaocha.plugin/capture-output must be present. If it is not present <system-out> will always be empty.

Resources

It was hard to find a definitive source of the Ant Junit XML format. I mostly went with this page for documentation.

For information on how to configure CircleCI to use this information, see store_test_results.

After reports that the output was not compatible with Azure Devops Pipeline the output was changed to adhere to this schema.

License

Copyright © 2018 Arne Brasseur

Available under the terms of the Eclipse Public License 1.0, see LICENSE.txt

Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close