kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
danielneal 2021-03-03T16:10:55.011300Z

Is there a way of getting kaocha to log each test it is running? I've hit an issue with some tests that have a subtle dependency between them, and I'm trying to debug it, but I need to know what order they are being run in.

dharrigan 2021-03-03T16:27:55.011500Z

I have this in my project root

dharrigan 2021-03-03T16:28:01.011700Z

❯ cat tests.edn 
#kaocha/v1
{:plugins [:kaocha.plugin/junit-xml
           :kaocha.plugin/cloverage
           :kaocha.plugin.alpha/spec-test-check]
 :reporter [kaocha.report/documentation]
 :fail-fast? true
:kaocha.plugin.junit-xml/target-file "target/junit.xml"}

dharrigan 2021-03-03T16:28:18.012100Z

running the tests will produce a. an xml file and b. a html file which you can open up in a browser

dharrigan 2021-03-03T16:28:21.012300Z

maybe that might help?

danielneal 2021-03-03T16:28:34.012600Z

oh yes, I think I have that too

danielneal 2021-03-03T16:28:43.012900Z

in fact I think it was your config I used 🙂

dharrigan 2021-03-03T16:28:47.013200Z

🙂

dharrigan 2021-03-03T16:28:56.013500Z

I do think that the ordering of the tests is non-deterministic

dharrigan 2021-03-03T16:29:02.013700Z

but <shrug>

danielneal 2021-03-03T16:29:20.014Z

yeah, it's randomized with a seed

danielneal 2021-03-03T16:29:25.014200Z

the error has gone away now 😄

danielneal 2021-03-03T16:29:29.014500Z

need to be ready next time

dharrigan 2021-03-03T16:29:33.014600Z

can you provide your own seed?

danielneal 2021-03-03T16:29:38.014900Z

I think you can

dharrigan 2021-03-03T16:29:39.015Z

so that it's run the same way each time?

2021-03-03T16:49:20.015200Z

You can also disable randomization

2021-03-03T16:50:00.015500Z

add

:kaocha.plugin.randomize/randomize? false

2021-03-03T16:50:07.015800Z

to the top level map in your tests.edn

dharrigan 2021-03-03T16:52:12.016Z

:thumbsup:

lread 2021-03-03T17:27:14.021300Z

If I remember correctly, even with randomize false, your tests are still first sorted by name before they are run. Clojure.test offers a way to specify test order via test-ns-hook but kaocha currently https://github.com/lambdaisland/kaocha/issues/29. Running tests in a specific order is of interest for a project I am working on that converts code blocks in docs to tests. These code blocks sometimes rely on each other, so running in order is important. I worked around the issue by using randomize false and generating test names that would sort appropriately.

lilactown 2021-03-03T17:44:27.022600Z

has anyone experienced this error when running kaocha on node.js in GitHub's CI?

Exception: clojure.lang.ExceptionInfo: Failed initializing ClojureScript runtime
full stack trace: https://github.com/lilactown/autonormal/runs/2006021070?check_suite_focus=true

lilactown 2021-03-03T17:45:18.023300Z

it's intermittent; re-running the tests typically fixes it. anecdotally I would say it fails every other time in CI. I haven't repro'd it locally yet

Alys Brooks 2021-03-03T17:58:56.023600Z

I haven't tried kaocha on GitHub CI myself. One thing you could try is experimenting with is the :cljs/timeout option to a value higher than 10000 (=10 s). It's possible node.js isn't consistently ready by the time those tests run.