kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
Charlie Briggs 2020-11-12T14:56:48.070800Z

is there a way to only fail fast for each deftest context? i.e. adapting this example https://cljdoc.org/d/lambdaisland/kaocha/0.0-359/doc/-fail-fast-option

Given a file named "test/my/project/fail_fast_test.clj" with:

(ns my.project.fail-fast-test
  (:require [clojure.test :refer :all]))

(deftest test-1
  (is true))

(deftest test-2
  (is true)
  (is false)
  (is true))

(deftest test-3
  (is true))

    When I run bin/kaocha --fail-fast

    Then the exit-code should be 1

    And the output should contain:

[(..F.)]

FAIL in my.project.fail-fast-test/test-2 (fail_fast_test.clj:9)
expected: false
  actual: false
3 tests, 4 assertions, 1 failures.

Charlie Briggs 2020-11-12T14:57:48.071Z

context is that for integration tests I don’t want to continue if a pre-condition has failed as the output becomes hard to follow

Charlie Briggs 2020-11-12T14:59:06.071200Z

I guess the equivalent from another language would be testify/assert vs testify/require in the Go library https://github.com/stretchr/testify

plexus 2020-11-12T15:00:18.071500Z

easiest would be to just throw an exception

plexus 2020-11-12T15:00:41.071700Z

that's what fail-fast does too under the hood, it's only way to "break out" of a running deftest

Charlie Briggs 2020-11-12T15:01:11.071900Z

ah, so I could in theory wrap is with something else, such as is-required and just throw out of it? That could work

plexus 2020-11-12T15:02:40.072300Z

something like that, or have your own variant of is which throws on failure. is by default catches all exceptions inside the is

Charlie Briggs 2020-11-12T15:06:57.072500Z

yup, just checked out the implementation which hadn’t inspected before. Thanks for your help!

Charlie Briggs 2020-11-12T15:12:00.072700Z

worked a charm :star-struck:

2020-11-12T22:35:19.076300Z

Hi all, I am trying to figure out how to specify a namespace exclusion with kaocha. Here's what is in my deps.edn:

:coverage    {:extra-deps {lambdaisland/kaocha-cloverage {:mvn/version "RELEASE"}}
                              :main-opts  ["-m" "kaocha.runner"
                                           "--plugin" "cloverage"
                                           "--ns-exclude-regex" "app.main"]}
The --ns-exclude regex should be a vector of regexes. I am not quite sure how to do this with deps. Do I do a literal list in the string?

plexus 2020-11-13T08:32:33.076900Z

start with bin/kaocha --help, you will see that there is no --ns-exclude-regex option, but there is a --cov-ns-exclude-regex

plexus 2020-11-13T08:33:06.077200Z

just pass it a string as you do now, if you want to pass more than one then specify the option more than once

2020-11-13T14:20:58.077400Z

thanks!