{"id":20936110,"url":"https://github.com/flow-storm/clofidence","last_synced_at":"2025-05-13T21:30:56.461Z","repository":{"id":207569677,"uuid":"719567722","full_name":"flow-storm/clofidence","owner":"flow-storm","description":"Bolster your Clojure test suite confidence","archived":false,"fork":false,"pushed_at":"2025-03-26T19:06:03.000Z","size":835,"stargazers_count":52,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T19:38:28.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flow-storm.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-16T12:53:09.000Z","updated_at":"2025-03-26T19:06:06.000Z","dependencies_parsed_at":"2023-11-16T14:27:55.142Z","dependency_job_id":"7ae62d35-46c4-4a7a-a0d7-86876fd4d4d4","html_url":"https://github.com/flow-storm/clofidence","commit_stats":null,"previous_names":["flow-storm/clofidence"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-storm%2Fclofidence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-storm%2Fclofidence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-storm%2Fclofidence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flow-storm%2Fclofidence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flow-storm","download_url":"https://codeload.github.com/flow-storm/clofidence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254030870,"owners_count":22002665,"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":[],"created_at":"2024-11-18T22:17:55.164Z","updated_at":"2025-05-13T21:30:56.438Z","avatar_url":"https://github.com/flow-storm.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clofidence\n\nBolster your Clojure[Script] test suite confidence. \n\n![screenshot](./images/screenshot.png)\n\nClofidence is a test coverage tool for Clojure and ClojureScript. \nIt will instrument your codebase using [ClojureStorm](https://github.com/flow-storm/clojure) or [ClojureScriptStorm](https://github.com/flow-storm/clojurescript), \nthen run your tests and generate a test coverage report.\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.github.flow-storm/clofidence.svg)](https://clojars.org/com.github.flow-storm/clofidence)\n\n## Clojure quick start\n\n### With the Clojure Cli\n\nAdd an alias to your `deps.edn` like this :\n\n```clojure\n{....\n :aliases \n {:test {...}\n  :clofidence {:classpath-overrides {org.clojure/clojure nil}\n               :extra-deps {com.github.flow-storm/clojure {:mvn/version \"1.12.0-9\"}\n                            com.github.flow-storm/clofidence {:mvn/version \"LATEST\"}}\n               :exec-fn clofidence.main/run\n               :exec-args {:report-name \"MyApp\"\n                           :test-fn cognitect.test-runner.api/test\n                           :test-fn-args [{}]}\n               :jvm-opts [\"-Dclojure.storm.instrumentAutoPrefixes=false\"\n                          \"-Dclojure.storm.instrumentOnlyPrefixes=my-app\"\n                          \"-Dclojure.storm.instrumentSkipPrefixes=my-app.unwanted-ns1,my-app.unwanted-ns2\"\n                          \"-Dclojure.storm.instrumentSkipRegex=.*test.*\"\n                          ]}}}\n```\n\nPlease make sure you have the latest versions of ClojureStorm and Clofidence.\n\nWith __Clofidence__ configured, every time you want to generate a coverage report you run :\n\n```bash\n$ clj -X:test:clofidence\n```\n\nAfter running the tests, it should generate a folder (by default called clofidence-output) with a index.html pointing to every ns details.\nClick [here](/examples/clojurescript-1.60.tgz) to download the Clofidence report for the ClojureScript compiler v1.11.60 as an example.\n\n### Configuration\n\nThe example above assumes your aliases contain a `:test` alias that will put the tests paths and test-runner \non the classpath, but this will depend on your particular test setup.\n\nThere is a lot going on in the configuration, so let's walk over it :\n\n  * First, we need to disable the official Clojure compiler, since we are going to replace it with ClojureStorm\n  * Next, we add the latest ClojureStorm and Clofidence dependencies\n  * `:exec-fn` and `:exec-args` tells the Clojure cli what  Clofidence main entry point is and with what arguments it should call it\n    * `:report-name` just configures the report header and file name\n    * `:test-fn` tells Clofidence what function will run your tests\n    * `:test-fn-args` are the arguments to the function defined in `:test-fn`\n    * `:output-folder` there an optional output folder, to provide a folder name, otherwise `clofidence-output` will be used\n  * Finally we need to tell Clofidence which namespaces to include and which to skip for the coverage\n    * `instrumentOnlyPrefixes` should be a comma separated list of namespaces prefixes to include. Adding `my-app` will include everything \n    under `my-app.core` and `my-app.web.routes`.\n    * `instrumentSkipPrefixes` can be used in the same way, but to skip unwanted namespaces.\n    * `instrumentSkipRegex` should be a regex to match namespaces to skip\n\n## ClojureScript quick start \n\n### With shadow-cljs\n\nMinimum requirements :\n\n* nodejs \u003e= 18.0.0 (when running tests with node)\n* shadow-cljs \u003e= 2.25.4\n    \nAdd an alias to your `deps.edn` like this :\n\n```clojure\n{....\n :aliases \n {:test {...}\n  :clofidence {:classpath-overrides {org.clojure/clojurescript nil}\n               :extra-deps {thheller/shadow-cljs {:mvn/version \"2.28.10\" :exclusions [org.clojure/clojurescript]}\n                            com.github.flow-storm/clojurescript {:mvn/version \"1.11.132-9\"} ;; checkout latest\n                            com.github.flow-storm/clofidence {:mvn/version \"LATEST\"}}\n               :exec-fn clofidence.main/run-cljs\n               :exec-args {:report-name \"MyApp\"}\n               :jvm-opts [\"-Dcljs.storm.instrumentOnlyPrefixes=org.foo,dev\"\n                          \"-Dcljs.storm.instrumentSkipPrefixes=dev.skipped\"\n                          \"-Dcljs.storm.instrumentSkipRegex=.*test.*\"\n                          \"-Dcljs.storm.instrumentEnable=true\"]}}}\n```\n\nModify your shadow-cljs.edn test builds (nodejs and browser currently supported) like this :\n\n```clojure\n{:deps {:aliases [:clofidence :test]}\n :dev-http {8021 \"out/test\"}\n :builds\n {:test-browser {:target :browser-test\n                 :test-dir \"out/test\"\n                 :runner-ns clofidence.shadow-test.browser\n                 :devtools {:preloads [clofidence.storm]}}\n  :test-node {:target :node-test\n              :output-to \"out/node-tests.js\"\n              :main clofidence.shadow-test.node/main\n              :devtools {:preloads [clofidence.storm]}}}}\n```\n\nAnd then spawn a clofidence server with :\n\n```bash\n$ clj -X:test:clofidence\n```\n\nYou should now be able to run your nodejs or browser tests as you normally do with shadow-cljs which for the browser will be something like :\n\n```bash\n$ npx shadow-cljs compile :test-browser # compile the tests\n$ npx shadow-cljs server # start the dev server\n$ firefox http://localhost:8021 # run the tests \n```\n\nwhile for nodejs will be something like :\n\n```bash\n$ npx shadow-cljs compile :test-node # compile the tests\n$ node out/node-tests.js # run the tests\n```\nAfter the tests run on the JS runtime, the results will be sent to your Clofidence server (the one you spawned before) which will generate\nthe reports on disk in its current folder.\n\nYou can now open your tests reports with something like :\n\n```bash\n$ firefox clofidence-output/index.html\n```\n\n### Configuration\n\nThe example above assumes your aliases contain a `:test` alias that will put the tests paths\non the classpath, but this will depend on your particular test setup.\n\nThere is a lot going on in the configuration, so let's walk over it :\n\n#### On deps.edn\n  * First, we need to disable the official ClojureScript compiler, since we are going to replace it with ClojureScriptStorm\n  * Next, we add the latest ClojureScriptStorm, Clofidence and shadow-cljs dependencies, excluidng the official ClojureScript compiler that comes with shadow-cljs\n  * `:exec-fn` and `:exec-args` tells the Clojure cli to run the clofidence server and with what arguments it should call it\n    * `:report-name` just configures the report header and file name\n    * `:output-folder` there an optional output folder, to provide a folder name, otherwise `clofidence-output` will be used\n  * Finally we need to tell Clofidence which namespaces to include and which to skip for the coverage\n    * `instrumentOnlyPrefixes` should be a comma separated list of namespaces prefixes to include. Adding `my-app` will include everything \n    under `my-app.core` and `my-app.web.routes`.\n    * `instrumentSkipPrefixes` can be used in the same way, but to skip unwanted namespaces.\n    * `instrumentSkipRegex` should be a regex to match namespaces to skip\n        \n    \n## Reports\n\n[Here](/examples/clojurescript-1.60.tgz) you can download and see the **Clofidence** report for the ClojureScript compiler v1.11.60.\n\nExtracting that tarball will give you a folder containing a index.html with an overview pointing to the rest of the files\nwhich contains each namespace details.\n\n### index.html\n\n#### Header counters\n\nThe **Total forms hit rate** shows how many top level forms were at least touched once by the tests, out of all the instrumented forms.\n\nThe **Total sub forms hit rate** shows how many sub-expressions were hit out of all instrumented ones.\n\n#### Header overview\n\nThe header overview shows one bar per namespace, and how much of it has been covered.\n\nThe size of the bars is proportional to the amount of code in the namespaces.\n\nClicking on the namespace name will take you to the namespace details.\n\n### Namespace detilas\n\n#### Form details\n  \nRight after the overview, the report includes a list of all your instrumented forms, grouped by namespaces and sorted by coverage.\n\nForms will have a green background if the coverage is \u003e 50%, a yellow background between 1% and 50% and a red background for forms with 0% coverage.\n\nEach forms contains details of what sub-expressions were hit at least once. This is useful to identify parts of your forms that aren't being exercised\nby the tests.\n\nHitted sub-expressions will be highlighted in green while hittable but not hit ones will be highlighted in red.\nSkimming over the red ones should give you an overview of uncovered conditional branches, uncovered functions signatures, etc.\n\n\n#### Which forms are included in the report?\n\nBy default, only forms with the first symbol name being one of : `defn`, `defn-`, `defmethod`, `extend-type`, `extend-protocol`, `deftype`, `defrecord` \nand `def` forms which define functions will be included.\n\nIf you have other types of forms (like the ones defined by some macros), you can include them by using `:extra-forms` in the configuration \nparameters. It takes a set of symbols like `:extra-forms #{defroutes}`.\n\nIf instead of using the default and allowing some extra forms you prefer the other way around, you can use the `:block-forms` config.\nIf you config it like `:block-forms #{}`, all forms will be included (with the exception of a few, see next) and you can block some\nby adding them to the set, like `:block-forms #{my-annoying-form}`.\n\nEven with `:block-forms #{}` there are some forms which are always excluded, which are `ns`, `defprotocol`, `quote`, `comment`, `def` with constants\nwhich doesn't make sense.\n\n## Known limitations\n\nExpressions that throw like (assert false) aren't being marked green even if they are \"hit\", because the don't return.\nClofidence marks as green every expression that evaluated, which assert doesn't because it throws.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflow-storm%2Fclofidence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflow-storm%2Fclofidence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflow-storm%2Fclofidence/lists"}