Skip to content

Commit 4e9e7e2

Browse files
authored
Merge pull request #331 from lambdaisland/alys/update-cucumber-docs
Update features from Cucumber feature tests.
2 parents 5a64319 + 061dfda commit 4e9e7e2

File tree

5 files changed

+123
-101
lines changed

5 files changed

+123
-101
lines changed

doc/command_line/print_config.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,46 @@
33
# CLI: Print the Kaocha configuration
44

55
A Kaocha test run starts with building up a Kaocha configuration map, based on
6-
default values, the contents of `tests.edn`, command line flags, and active
7-
plugins.
8-
9-
Debugging issues with Kaocha often starts with inspecting the configuration,
10-
which is why a `--print-config` flag is provided. This builds up the
11-
configuration from any available sources, runs it through any active plugins,
12-
and then pretty prints the result, an EDN map.
6+
default values, the contents of `tests.edn`, command line flags, and active
7+
plugins.
8+
9+
Debugging issues with Kaocha often starts with inspecting the configuration,
10+
which is why a `--print-config` flag is provided. This builds up the
11+
configuration from any available sources, runs it through any active plugins,
12+
and then pretty prints the result, an EDN map.
13+
14+
Note that the ordering, while not expected to change, is not guaranteed. We
15+
recommend parsing the configuration as EDN and not relying on order. If you
16+
are manipulating the output as text (say, on the command line) and can't
17+
avoid relying on the order, run it through a tool like
18+
[puget](https://github.com/greglook/puget) or
19+
[zprint](https://github.com/kkinnear/zprint) that sorts the keys
20+
alphabetically first.
1321

1422
## Using `--print-config`
1523

1624
- <em>When </em> I run `bin/kaocha --print-config`
1725

18-
- <em>Then </em> the output should contain:
26+
- <em>Then </em> the EDN output should contain:
1927

2028
``` clojure
2129
{:kaocha.plugin.randomize/randomize? false,
2230
:kaocha/reporter [kaocha.report/dots],
2331
:kaocha/color? false,
24-
:kaocha/fail-fast? false,
32+
:kaocha/fail-fast? false}
2533
```
2634

2735

28-
- <em>And </em> the output should contain:
36+
- <em>And </em> the EDN output should contain:
2937

3038
``` clojure
31-
:kaocha/tests
39+
{:kaocha/tests
3240
[{:kaocha.testable/type :kaocha.type/clojure.test,
3341
:kaocha.testable/id :unit,
3442
:kaocha/ns-patterns ["-test$"],
3543
:kaocha/source-paths ["src"],
3644
:kaocha/test-paths ["test"],
37-
:kaocha.filter/skip-meta [:kaocha/skip]}],
45+
:kaocha.filter/skip-meta [:kaocha/skip]}]}
3846
```
3947

4048

doc/plugins/notifier_plugin.md

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,33 @@
33
# Plugin: Notifier (desktop notifications)
44

55
Desktop notifications can be enabled with the `:kaocha.plugin/notifier`
6-
plugin. This will pop up a fail/pass notification bubble including a summary
7-
of tests passed/errored/failed at the end of each test run. It's particularly
8-
useful in combination with `--watch`, e.g. `bin/kaocha --plugin notifier
9-
--watch`.
10-
11-
It does this by invoking a shell command that can be configured, so it can be
12-
used to invoke an arbitrary command or script. By default, it will try to detect
13-
which command to use, using either `notify-send` (Linux) or `terminal-notifier`
14-
(Mac OS X), either of which may need to be installed first. If those commands
15-
aren't available, it uses Java's included notifier.
16-
17-
Several replacement patterns are available:
18-
19-
- `%{title}` : The notification title, either `⛔️ Failing` or `✅ Passing`
20-
- `%{message}` : Test result summary, e.g., `5 tests, 12 assertions, 0 failures`
21-
- `%{icon}` : Full local path to an icon to use (currently uses the Clojure icon)
22-
- `%{failed?}` : `true` if any tests failed or errored, `false` otherwise
23-
- `%{count}` : the number of tests
24-
- `%{pass}` : the number of passing assertions
25-
- `%{fail}` : the number of failing assertions
26-
- `%{error}` : the number of errors
27-
- `%{pending}` : the number of pending tests
28-
- `%{urgency}` : `normal` if the tests pass, `critical` otherwise, meant for use with `notify-send`
29-
- '%{timeout}` : configured timeout in milliseconds before the notification should disappear. By
30-
default, it passes -1, which corresponds to the default timeout when using
31-
`notify-send`.
32-
33-
Note that notifications don't time out on
34-
[GNOME](https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/112) and Ubuntu when
35-
using [Notify
36-
OSD](https://bugs.launchpad.net/ubuntu/+source/notify-osd/+bug/390508).
37-
38-
If no command is configured, and neither notification command is found, then
39-
the plugin will print a warning. You can explicitly inhibit its behaviour
40-
with `--no-notifications`.
41-
42-
You can combine the feature with the profiles feature:
43-
44-
45-
``` clojure
46-
{:plugins #profile {:default [:kaocha.plugin/notifier]
47-
:ci []}}
48-
```
49-
50-
This will silence the "Notification not shown because system does not support
51-
it." warning.
6+
plugin. This will pop up a fail/pass notification bubble including a summary
7+
of tests passed/errored/failed at the end of each test run. It's particularly
8+
useful in combination with `--watch`, e.g. `bin/kaocha --plugin notifier
9+
--watch`.
10+
11+
It does this by invoking a shell command which can be configured, so it can be
12+
used to invoke an arbitrary command or script. By default it will try to
13+
detect which command to use, using either `notify-send` (Linux) or
14+
`terminal-notifier` (Mac OS X), either of which may need to be installed
15+
first.
16+
17+
Several replacement patterns are available:
18+
19+
- `%{title}` : The notification title, either `⛔️ Failing` or `✅ Passing`
20+
- `%{message}` : Test result summary, e.g. `5 tests, 12 assertions, 0 failures`
21+
- `%{icon}` : Full local path to an icon to use (currently uses the Clojure icon)
22+
- `%{failed?}` : `true` if any tests failed or errored, `false` otherwise
23+
- `%{count}` : the number of tests
24+
- `%{pass}` : the number of passing assertions
25+
- `%{fail}` : the number of failing assertions
26+
- `%{error}` : the number of errors
27+
- `%{pending}` : the number of pending tests
28+
- `%{urgency}` : `normal` if the tests pass, `critical` otherwise, meant for use with `notify-send`
29+
30+
If no command is configured, and neither notification command is found, then
31+
the plugin will silently do nothing. You can explicitly inhibit its behaviour
32+
with `--no-notifications`.
5233

5334
## Enabling Desktop Notifications
5435

doc/plugins/orchestra_plugin.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ instruments your functions.
5959
``` nil
6060
ERROR in orchestra-test/spec-fail-test (orchestra_test.clj:11)
6161
Just testing simple-fn
62-
Call to #'orchestra-test/simple-fn did not conform to spec.
62+
Call to orchestra-test/simple-fn did not conform to spec.
6363
orchestra_test.clj:11
6464
6565
-- Spec failed --------------------
6666
67+
Return value
68+
6769
"x"
6870
6971
should satisfy

doc/spec_test_check.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
# Automatic spec test check generation
44

55
Kaocha can discover all of your fdefs and generate `clojure.spec.test.check`
6-
tests for them. This saves you the trouble of writing your own boilerplate,
7-
and gives you the truly "free" generative testing that clojure.spec promises.
8-
9-
There are two ways you can use this feature:
10-
11-
1. Adding `:kaocha.type/spec.test.check` test suites to your `tests.edn`:
12-
- `:kaocha.testable/type` = :kaocha.type/spec.test.check
13-
- `:kaocha/source-paths`: Normally your fdefs are with your code, so this
14-
can probably be left defaulted at `["src"]`
15-
- `:kaocha.spec.test.check/checks`: Optional. If you want to
16-
orchestrate multiple "sets" of checks with differing parameters, you can
17-
specify them here. This is a collection of checks, each check being a map
18-
which may contain the following optional keys:
19-
- `:kaocha.spec.test.check/syms`: Currently your only options are either
20-
`:all-fdefs` (default) or to provide a set of the symbols for the fdefs
21-
which you want to test. Eventually we will add `:other-fdefs` to select
22-
all the fdefs that were not specifically mentioned in other checks.
23-
- `:clojure.spec.test.check/instrument?` Turn on orchestra instrumentation
24-
during fdef checks
25-
- `:clojure.spec.test.check/check-asserts?` Run s/check-asserts during fdef
26-
checks
27-
- `:clojure.spec.test.check/opts`: A map containing any of:
28-
- `:num-tests`: Test iterations per fdef
29-
- `:max-size`: Maximum length of generated collections
30-
- All of the keys within each check can also be given in the top-level test
31-
suite map to be merged by default into all checks.
32-
2. The `kaocha.plugin.alpha/spec-test-check` plugin
33-
- This provides a sane default test suite for automatically checking all of
34-
your fdefs. Spec test checking can be configured with more granularity in
35-
tests.edn (as above), but the plugin exists for easy and simplistic CLI
36-
control.
37-
- Regardless of whether you add the test suite(s) to `tests.edn` yourself,
38-
you can also use this plugin to forceably override certain test
39-
parameters:
40-
- `--[no-]stc-instrumentation` = `:clojure.spec.test.check/instrument?`
41-
- `--[no-]stc-asserts` = `:clojure.spec.test.check/check-asserts?`
42-
- `--stc-num-tests NUM` = `:num-tests`
43-
- `--stc-max-size SIZE` = `:max-size`
44-
- By default, this plugin also adds `:no-gen` to `:kaocha.filter/skip-meta`.
45-
You might want to decorate an fdef-ed function with `^:no-gen` if there is
46-
either no good generator for one or more of its arguments or if the
47-
function is side-effectful.
6+
tests for them. This saves you the trouble of writing your own boilerplate,
7+
and gives you the truly "free" generative testing that clojure.spec promises.
8+
9+
There are two ways you can use this feature:
10+
11+
1. Adding `:kaocha.type/spec.test.check` test suites to your `tests.edn`:
12+
- `:kaocha.testable/type` = :kaocha.type/spec.test.check
13+
- `:kaocha/source-paths`: Normally your fdefs are with your code, so this
14+
can probably be left defaulted at `["src"]`
15+
- `:kaocha.spec.test.check/checks`: Optional. If you want to
16+
orchestrate multiple "sets" of checks with differing parameters, you can
17+
specify them here. This is a collection of checks, each check being a map
18+
which may contain the following optional keys:
19+
- `:kaocha.spec.test.check/syms`: Currently your only options are either
20+
`:all-fdefs` (default) or to provide a set of the symbols for the fdefs
21+
which you want to test. Eventually we will add `:other-fdefs` to select
22+
all the fdefs that were not specifically mentioned in other checks.
23+
- `:kaocha.spec.test.check/instrument?` Turn on orchestra instrumentation
24+
during fdef checks
25+
- `:kaocha.spec.test.check/check-asserts?` Run s/check-asserts during fdef
26+
checks
27+
- `:clojure.spec.test.check/opts`: A map containing any of:
28+
- `:num-tests`: Test iterations per fdef
29+
- `:max-size`: Maximum length of generated collections
30+
- All of the keys within each check can also be given in the top-level test
31+
suite map to be merged by default into all checks.
32+
2. The `kaocha.plugin.alpha/spec-test-check` plugin
33+
- This provides a sane default test suite for automatically checking all of
34+
your fdefs. Spec test checking can be configured with more granularity in
35+
tests.edn (as above), but the plugin exists for easy and simplistic CLI
36+
control.
37+
- Regardless of whether you add the test suite(s) to `tests.edn` yourself,
38+
you can also use this plugin to forceably override certain test
39+
parameters:
40+
- `--[no-]stc-instrumentation` = `:kaocha.spec.test.check/instrument?`
41+
- `--[no-]stc-asserts` = `:kaocha.spec.test.check/check-asserts?`
42+
- `--stc-num-tests NUM` = `:num-tests`
43+
- `--stc-max-size SIZE` = `:max-size`
44+
- By default, this plugin also adds `:no-gen` to `:kaocha.filter/skip-meta`.
45+
You might want to decorate an fdef-ed function with `^:no-gen` if there is
46+
either no good generator for one or more of its arguments or if the
47+
function is side-effectful.
4848

4949
## Detects and checks fdefs using tests.edn
5050

doc/syntax_error.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- This document is generated based on a corresponding .feature file, do not edit directly -->
2+
3+
# Syntax errors are preserved
4+
5+
Syntax errors should be passed along.
6+
7+
## Show output of failing test
8+
9+
- <em>Given </em> a file named "test/sample_test.clj" with:
10+
11+
``` clojure
12+
(ns sample-test
13+
(:require [clojure.test :refer :all]))
14+
15+
stray-symbol
16+
17+
(deftest stdout-pass-test
18+
(is (= :same :same)))
19+
```
20+
21+
22+
- <em>When </em> I run `bin/kaocha`
23+
24+
- <em>Then </em> the output should contain:
25+
26+
``` nil
27+
Exception: clojure.lang.Compiler$CompilerException
28+
```
29+
30+
31+

0 commit comments

Comments
 (0)