|
3 | 3 | # Automatic spec test check generation
|
4 | 4 |
|
5 | 5 | 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. |
48 | 48 |
|
49 | 49 | ## Detects and checks fdefs using tests.edn
|
50 | 50 |
|
|
0 commit comments