# The best test runner? kaocha or something else?

**URL:** https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746
**Category:** General Questions
**Created:** [January 27, 2023, 2:43pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746 "2023-01-27T14:43:23Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![felix1](https://clojureverse.org/letter_avatar_proxy/v4/letter/f/3e96dc/32.png) [@felix1](https://clojureverse.org/u/felix1)
#### Post date: [January 27, 2023, 2:43pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/1 "2023-01-27T14:43:23Z")

</div>

Hello,

Recently I googled how to output of failed tests of functions that return a map with a lot of keys and I found [kaocha](https://github.com/lambdaisland/kaocha). That really surprised me since I haven’t realized that people created another test runners. So far I always just run tests using Leiningen but kaocha has sooo much better output.

Could you please tell me are there any other test runners that I should try before I switch all my projects to kaocha?

Are there any differences in speed when running all tests using different test runners?

Thank you.

Best regards,

Felix

---

<div class="post-metadata">

### Author: ![borkdude](https://clojureverse.org/user_avatar/clojureverse.org/borkdude/32/306_2.png) [@borkdude](https://clojureverse.org/u/borkdude)
#### Post date: [January 27, 2023, 4:27pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/2 "2023-01-27T16:27:07Z")

</div>

I tend to use the [cognitect test runner](https://github.com/cognitect-labs/test-runner) a lot too which is the most basic one for `deps.edn` projects. For getting better output when matching data structures, check out [matcher-combinators](https://github.com/nubank/matcher-combinators). That works with any test runner. You can implement failing fast pretty easily yourself ([example](https://github.com/babashka/babashka/blob/b2855d1212dc9d70dff54e3b79b7d58b58613ede/test/babashka/test_utils.clj#L34-L44)). Kaocha comes with those features out of the box.

[eftest](https://github.com/weavejester/eftest) is pretty good too.

For testing CLJS, I like [cljs-test-runner](https://github.com/Olical/cljs-test-runner) a lot since it’s API-compatible with the Cognitect test runner and works well with advanced compilation.

---

<div class="post-metadata">

### Author: ![seancorfield](https://clojureverse.org/user_avatar/clojureverse.org/seancorfield/32/195_2.png) [@seancorfield](https://clojureverse.org/u/seancorfield)
#### Post date: [January 27, 2023, 11:34pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/3 "2023-01-27T23:34:18Z")

</div>

Like Michiel, I use the Cognitect test-runner – because all my projects are `deps.edn` now, not Leiningen – but you can use [pjstadig/humane-test-output: Humane test output for clojure.test. (github.com)](https://github.com/pjstadig/humane-test-output/) with that test-runner to get a lot of the same benefits, in terms of output, that Kaocha provides (although, with `test-runner` and `deps.edn`, you do need to do a little work to actually _activate_ HTO whereas it is much easier with Leiningen).

Since you’re still using Leiningen, you might want to try HTO first, since you wouldn’t need to change much about how you run tests.

---

<div class="post-metadata">

### Author: ![dpassen](https://clojureverse.org/user_avatar/clojureverse.org/dpassen/32/5359_2.png) [@dpassen](https://clojureverse.org/u/dpassen)
#### Post date: [January 28, 2023, 12:01am UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/4 "2023-01-28T00:01:56Z")

</div>

kaocha works great with `deps.edn` projects. I use it for its ability to randomize test order and capture standard out.

---

<div class="post-metadata">

### Author: ![borkdude](https://clojureverse.org/user_avatar/clojureverse.org/borkdude/32/306_2.png) [@borkdude](https://clojureverse.org/u/borkdude)
#### Post date: [January 29, 2023, 7:40pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/5 "2023-01-29T19:40:24Z")

</div>

Btw, it’s easy to at kaocha or the cognitect test runner to an existing deps.edn project with [neil](https://github.com/babashka/neil):

```auto
$ neil add kaocha

```

or

```auto
$ neil add test

```

is all you need to do in a project.

It’s recommended to upgrade to the latest `neil` if you already have it installed since it’s gotten some improvements related to this today.

---

<div class="post-metadata">

### Author: ![jr0cket](https://clojureverse.org/user_avatar/clojureverse.org/jr0cket/32/670_2.png) [@jr0cket](https://clojureverse.org/u/jr0cket)
#### Post date: [January 30, 2023, 11:24am UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/6 "2023-01-30T11:24:04Z")

</div>

[Test Runners - Practicalli Clojure](https://practical.li/clojure/testing/test-runners/) covers the test runner tools I’ve used. They are all very good tools to use, so choose which one fits the needs most appropriately

> **[Test Runners - Practicalli Clojure](https://practical.li/clojure/testing/test-runners/)**
>
> Practical guide to Clojure programming language and Clojure REPL driven development

After trying several Clojure test runners I decided to use lambdaisland/kaocha, as it’s easy to work with and can make for a very efficient test workflow

I use kaocha via `:test/run` and `:test/watch` aliases in the Clojure CLI user config, so it’s very simple to use with any project. A `test.edn` file is added to a project to tailor/optimise the test workflow where required

Overall I found kaocha useful because:

- simple to use - although config is recommended it is not essential
- fail fast - so I don’t get too many failed tests
- watch mode - for automatically running tests on file save, which I run in a separate terminal window and occasional glance at
- profiling - lists the slowest tests for each test category
- highly configurable - can be very specific on which tests should be run
- nice test reporter options with useful output

There is also editor integration with Emacs, which I’ve used with Doom Emacs & Spacemacs (which was quite simple to add)

---

<div class="post-metadata">

### Author: ![rmschindler](https://clojureverse.org/user_avatar/clojureverse.org/rmschindler/32/3638_2.png) [@rmschindler](https://clojureverse.org/u/rmschindler)
#### Post date: [February 22, 2023, 6:48pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/7 "2023-02-22T18:48:55Z")

</div>

I too am curious about what test runners are available. From some comments I read—albeit old ones—apparently Kaocha doesn’t work with shadow-cljs—is this true? And if so, what test runner(s) would you all recommend that does work with shadow-cljs?

---

<div class="post-metadata">

### Author: ![Bb98](https://clojureverse.org/letter_avatar_proxy/v4/letter/b/7cd45c/32.png) [@Bb98](https://clojureverse.org/u/Bb98)
#### Post date: [July 21, 2023, 12:06am UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/8 "2023-07-21T00:06:28Z")

</div>

Kaocha is a bit heavyweight so I resisted it for a while, but it is the easiest way to export junit output for integration into CI (eg gitlab/teamcity) so now use it for everything.

During repl/development I just use the normal run-test and/or IntelliJ integration.

---

<div class="post-metadata">

### Author: ![zcaudate1](https://clojureverse.org/user_avatar/clojureverse.org/zcaudate1/32/5459_2.png) [@zcaudate1](https://clojureverse.org/u/zcaudate1)
#### Post date: [July 21, 2023, 2:53am UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/9 "2023-07-21T02:53:57Z")

</div>

I’d say the best test runner is the one you’ve built for yourself.

For me, it’s the [midje](https://github.com/marick/Midje) inspired - [code.test](https://github.com/zcaudate/foundation-base/blob/main/src/code/test.clj). Definitely not as full featured as kaocha or the clojure.test ecosystem. Testing and displaying errors on maps with lots of keys is a problem that is yet to be solved.

However, it’s super simple to both maintain and modify, with a fraction of the code of most test runners.

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [January 19, 2024, 2:54pm UTC](https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/10 "2024-01-19T14:54:23Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
