{"id":18993078,"url":"https://github.com/redbadger/test-report","last_synced_at":"2025-04-22T11:48:04.010Z","repository":{"id":62433417,"uuid":"81110182","full_name":"redbadger/test-report","owner":"redbadger","description":"Test reporting for clojure.test","archived":false,"fork":false,"pushed_at":"2023-02-25T13:55:30.000Z","size":39,"stargazers_count":10,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T23:38:35.132Z","etag":null,"topics":["clojure","test-reporting"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redbadger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-06T16:59:27.000Z","updated_at":"2024-09-21T15:12:51.000Z","dependencies_parsed_at":"2022-11-01T21:16:02.071Z","dependency_job_id":null,"html_url":"https://github.com/redbadger/test-report","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redbadger%2Ftest-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redbadger%2Ftest-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redbadger%2Ftest-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redbadger%2Ftest-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redbadger","download_url":"https://codeload.github.com/redbadger/test-report/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237793,"owners_count":21397399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","test-reporting"],"created_at":"2024-11-08T17:19:49.466Z","updated_at":"2025-04-22T11:48:03.982Z","avatar_url":"https://github.com/redbadger.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# test-report\n\n[![CircleCI](https://circleci.com/gh/redbadger/test-report.svg?style=svg)](https://circleci.com/gh/redbadger/test-report)\n\ntest-report is a tool for customizing clojure.test output.\n\n## Installation\n\nThe easiest way to get started is to add the lein-test-report plugin to your [Leiningen](https://github.com/technomancy/leiningen) project map.\nAs it's only used in tests, it's best to add it only to the `:test` profile:\n\n```clojure\n:profiles {:test {:plugins [[lein-test-report \"0.2.0\"]]}}\n```\n\n## Usage\n\ntest-report hooks into the [`clojure.test/run-tests`](https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/run-tests) function, so will automatically be included when running `lein test`.\n\nBy default, the configuration is identical to the clojure.test defaults, so you won't see any difference.\nTo start customizing the output, you'll need to provide some reporters or summarizers.\n\n### Reporters\n\nAs your tests run, clojure.test passes messages to [`clojure.test/report`](https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/report).\nThe default implementation prints relevant details to stdout.\nLeiningen [enhances the output](https://github.com/technomancy/leiningen/blob/2.7.1/src/leiningen/test.clj#L96-L111) by including commands that can be used to re-run individual tests.\n\nTo override this output, you can provide a collection of reporters to test-report, which are called sequentially with each message reported during the test run.\nFor example, to pretty-print the message to stdout, add the following to the `:test` profile:\n\n```clojure\n:injections [(require 'clojure.pprint)]\n:test-report {:reporters [clojure.pprint/pprint]}\n```\n\nNotice how namespaces not already used in your tests need to be required in an injection.\n\nThe resulting output, which might be useful when developing your own reporters, looks something like\n\n```console\n$ lein test\n{:type :begin-test-ns,\n :ns #object[clojure.lang.Namespace 0x66fdec9 \"example.test\"],\n :time 45906184724820}\n{:type :begin-test-var,\n :var #'example.test/arithmetic,\n :time 45906212298330}\n{:type :pass,\n :expected (= 4 (+ 2 2)),\n :actual\n (#object[clojure.core$_EQ_ 0x3016fd5e \"clojure.core$_EQ_@3016fd5e\"]\n  4\n  4),\n :message nil,\n :time 45906216409445,\n :context (\"with positive integers\" \"addition\")}\n{:type :pass,\n :expected (= 7 (+ 3 4)),\n :actual\n (#object[clojure.core$_EQ_ 0x3016fd5e \"clojure.core$_EQ_@3016fd5e\"]\n  7\n  7),\n :message nil,\n :time 45906232042175,\n :context (\"with positive integers\" \"addition\")}\n{:type :end-test-var,\n :var #'example.test/arithmetic,\n :time 45906241926006}\n{:type :end-test-ns,\n :ns #object[clojure.lang.Namespace 0x66fdec9 \"example.test\"],\n :time 45906243742590}\n{:test 1,\n :pass 0,\n :fail 0,\n :error 0,\n :type :summary,\n :time 45906248308974}\n```\n\nNote that the final summary message does not have accurate counts; the original implementation of `clojure.test/report` is not being called, so the counters are not being incremented.\nWhen implementing your own reporter, you may need to call [`clojure.test/inc-report-counter`](https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/inc-report-counter) yourself.\n\nThe messages passed to the reporters have some extra information compared to those originally passed to `clojure.test/report`.\nA nanosecond offset `:time` is added to all messages, which can be used to calculate the test execution time.\nTest results (`:pass`, `:fail`, or `:error` messages) also have `:context`, which is the list of strings passed to [`clojure.test/testing`](https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/testing), ordered from innermost to outermost.\n\n### Summarizers\n\nTo produce output based on aggregate test results (for example, a [JUnit XML report](https://github.com/redbadger/test-report-junit-xml)), reporters would have to keep track of previous messages in a mutable data structure.\nIn this case, it may be simpler to use a summarizer.\nEach summarizer is called at the end of the test run, and passed a vector of all the messages that were reported.\nFor example, to pretty-print the messages to stdout:\n\n```clojure\n:injections [(require 'clojure.pprint)]\n:test-report {:summarizers [clojure.pprint/pprint]}\n```\n\n```console\n$ lein test\n\nTesting example.test\n\nRan 1 tests containing 2 assertions.\n0 failures, 0 errors.\n[{:type :begin-test-ns,\n  :ns #object[clojure.lang.Namespace 0x1b73be9f \"example.test\"],\n  :time 46558525944477}\n {:type :begin-test-var,\n  :var #'example.test/arithmetic,\n  :time 46558529380772}\n {:type :pass,\n  :expected (= 4 (+ 2 2)),\n  :actual\n  (#object[clojure.core$_EQ_ 0x5ccbeb64 \"clojure.core$_EQ_@5ccbeb64\"]\n   4\n   4),\n  :message nil,\n  :time 46558532202149,\n  :context (\"with positive integers\" \"addition\")}\n {:type :pass,\n  :expected (= 7 (+ 3 4)),\n  :actual\n  (#object[clojure.core$_EQ_ 0x5ccbeb64 \"clojure.core$_EQ_@5ccbeb64\"]\n   7\n   7),\n  :message nil,\n  :time 46558533416008,\n  :context (\"with positive integers\" \"addition\")}\n {:type :end-test-var,\n  :var #'example.test/arithmetic,\n  :time 46558534111792}\n {:type :end-test-ns,\n  :ns #object[clojure.lang.Namespace 0x1b73be9f \"example.test\"],\n  :time 46558534219611}\n {:test 1,\n  :pass 2,\n  :fail 0,\n  :error 0,\n  :type :summary,\n  :time 46558534317550}]\n```\n\nThe `test-report.summary/summarize` function collates the messages into a more usable form:\n\n```clojure\n:injections [(require 'clojure.pprint 'test-report.summary)]\n:test-report {:summarizers [(comp clojure.pprint/pprint test-report.summary/summarize)]}\n```\n\n```console\n$ lein test\n\nTesting example.test\n\nRan 1 tests containing 2 assertions.\n0 failures, 0 errors.\n{:namespaces\n [{:ns\n   #object[clojure.lang.Namespace 0x31000e60 \"example.test\"],\n   :time 7656556,\n   :tests\n   [{:var #'example.test/arithmetic,\n     :time 2690626,\n     :results\n     ({:type :pass,\n       :expected (= 4 (+ 2 2)),\n       :actual\n       (#object[clojure.core$_EQ_ 0x42f8285e \"clojure.core$_EQ_@42f8285e\"]\n        4\n        4),\n       :message nil,\n       :context (\"with positive integers\" \"addition\")}\n      {:type :pass,\n       :expected (= 7 (+ 3 4)),\n       :actual\n       (#object[clojure.core$_EQ_ 0x42f8285e \"clojure.core$_EQ_@42f8285e\"]\n        7\n        7),\n       :message nil,\n       :context (\"with positive integers\" \"addition\")})}],\n   :summary {:test 1, :assertion 2, :fail 0, :error 0, :pass 2}}],\n :summary {:test 1, :assertion 2, :fail 0, :error 0, :pass 2}}\n```\n\n## License\n\nCopyright © 2017 Red Badger\n\nDistributed under the Eclipse Public License either version 1.0 or (at your option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredbadger%2Ftest-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredbadger%2Ftest-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredbadger%2Ftest-report/lists"}