Skip to content
Back to skills

Clojure Testing

ASecurity

clojure.test and test frameworks — use when a slow full suite should not be rerun for one test or namespace (kaocha --focus, test-runner -v/-n, lazytest -v), when a green test run may have selected no tests (a misspelled var or an empty focus selector), or when writing or running unit or property tests, adding fixtures, choosing a test runner, or diagnosing a failing test.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgobashtestingdocumentation

Works with

  • cli

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add just-sultanov/clojure-skills --skill clojure-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clojure Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clojure Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/just-sultanov-clojure-testing/badge)](https://www.skillsdirectory.com/skills/just-sultanov-clojure-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clojure-testing
description: clojure.test and test frameworks — use when a slow full suite should not be rerun for one test or namespace (kaocha --focus, test-runner -v/-n, lazytest -v), when a green test run may have selected no tests (a misspelled var or an empty focus selector), or when writing or running unit or property tests, adding fixtures, choosing a test runner, or diagnosing a failing test.
license: CC-BY-3.0 AND EPL-1.0 AND EPL-2.0
---

# Clojure Testing

Owns writing and running tests: the `clojure.test` conventions and
fixtures, `test.check` properties, the cognitect test-runner, `kaocha`, and
`lazytest`, selecting which tests run, and reading a failure. `deps.edn`
alias mechanics and CI wiring belong to `clojure-deps`; the REPL session
belongs to `clojure-repl`; `bb` test tasks belong to `clojure-babashka`;
version gates belong to `clojure-versions`; naming and layout outside test
files belong to `clojure-style`. The text is adapted from the `clojure.test`
sources, the test.check, test-runner, kaocha, and lazytest documentation,
and the testing rules of the Clojure style guide under EPL 1.0, EPL 2.0,
and CC BY 3.0; see [NOTICE.md](NOTICE.md).

## Ground rules

- **`clojure.test` is the baseline.** Ordinary tests need no library beyond
  it. Add a runner when the CLI must discover or select tests; switch
  frameworks only when the project asks for one, and never into a suite
  that already uses another.
- **The suite fails the process.** `run-tests` prints a summary and returns
  counters; it sets no exit code. The runner — cognitect, kaocha, lazytest,
  or a bespoke one — exits non-zero on any failure or error; CI reads only
  the code.
- **An empty selection is not a pass.** A selector that matches no tests can
  still exit 0. Read the test count, not only the exit code: zero tests means
  the selection was wrong, not that the suite is green.
- **Tests are independent.** No shared mutable state, no order dependency,
  and no `Thread/sleep` as a synchronization device. A randomized order
  must not change the outcome.
- **A property complements an example.** A test.check property stays
  deterministic for a seed, shrinks to a minimal failing case, and replaces
  no named example.

## Workflow

### 1. Read the test setup

Read the `deps.edn` aliases, `tests.edn`, `bb.edn`, and the CI job that runs
the suite; open one neighbouring test namespace. Note the framework in use,
the command that runs it, where tests live, and the naming the project
actually follows.

Done when you can name the framework, the runner command, and the test
directory.

### 2. Write the test

Follow [conventions.md](references/conventions.md): mirror the source
namespace, one concept per `deftest`, `testing` blocks for sub-cases, `are`
for input tables, an `is` message where the form cannot explain the
failure, `with-redefs` only at an external boundary. Shared setup goes in a
fixture, not a top-level mutable `def`
([clojure-test.md](references/clojure-test.md)); asynchronous code blocks
inside the body with a timeout
([clojure-test.md](references/clojure-test.md)); a property follows
[test-check.md](references/test-check.md).

Done when the test runs and a failure would name its scenario without
reading the assertions.

### 3. Select what runs

Never rerun a whole suite to watch one test:

| Scope         | At the REPL (`clojure.test`)      | cognitect `-M`/`-X`               | kaocha                 | lazytest                    |
| ------------- | --------------------------------- | --------------------------------- | ---------------------- | --------------------------- |
| one var       | `(run-test 'my.ns/x-test)` 1.11+  | `-v my.ns/x-test`, `:vars`        | `--focus my.ns/x-test` | `-v my.ns/x-test`           |
| one namespace | `(run-tests 'my.ns)`              | `-n my.ns`, `:nses`               | `--focus my.ns`        | `-n my.ns`                  |
| by metadata   | tag the var; select in the runner | `-i :slow`, `:includes '[:slow]'` | `--focus-meta :slow`   | `-i :slow`, `{:focus true}` |

REPL calls are `clojure.test`'s: `run-test`/`run-test-var` apply the
namespace fixtures and need Clojure 1.11; a bare `test-var` applies none.
The full flag lists are in [runners.md](references/runners.md) and
[lazytest.md](references/lazytest.md).

Done when the output shows that only the intended tests ran and the count is
not zero.

### 4. Add or configure a runner

Choose by the feature the project lacks, write the `:test` alias or
`tests.edn` with the recipes in [runners.md](references/runners.md) and
[lazytest.md](references/lazytest.md), and keep the exit-code rule.

Done when the command runs the whole suite from a clean checkout and exits
non-zero on a deliberately broken assertion.

### 5. Diagnose a failure

Read the report before the code: FAIL is a false assertion, ERROR is an
uncaught exception; the `testing` string names the scenario and the `is`
message the expectation. Reproduce at the REPL, shrink the input, fix, and
rerun the selection, then the suite. The hunt is in
[failures.md](references/failures.md).

Done when the test that motivated the task passes and no neighbour changed.

## Checklist

- [ ] The framework matches the project's; no second framework in one suite.
- [ ] Test namespaces mirror the source and end in `-test`; vars end in
      `-test`.
- [ ] One concept per `deftest`; sub-cases sit under `testing` strings.
- [ ] `is` messages explain failures the form cannot; `are` covers input
      tables; exceptions are asserted with `thrown?`/`thrown-with-msg?`.
- [ ] Shared setup is a fixture that calls `f` exactly once and cleans up.
- [ ] Async bodies block with a timeout, and the timeout itself is asserted.
- [ ] The runner exits non-zero on failure; the command works from a clean
      checkout.
- [ ] Only the intended tests were selected, and the run was not empty.
- [ ] A failing property reports its seed and its shrunk smallest case.
- [ ] The motivating test passes; its neighbours did not change.

## Related skills

- `clojure-deps` — the `:test` alias exec modes, the classpath, and CI
  pinning and caching around the test command.
- `clojure-repl` — reloading after an edit, `*e`, and shrinking a failing
  form at the prompt; the session side of the diagnosis workflow.
- `clojure-babashka` — `bb` test tasks, the `test-runner.clj` pattern, and
  the built-in `clojure.test.check` feature gate.
- `clojure-style` — naming, layout, and idiom outside test files; the
  test-specific conventions live here.
- `clojure-versions` — `run-test` needs 1.11; `ExceptionInfo` is a default
  import from 1.13.

## References

| File                                          | Read when                                                                        |
| --------------------------------------------- | -------------------------------------------------------------------------------- |
| [conventions.md](references/conventions.md)   | writing or reviewing a test's shape: naming, `testing`, `are`, mocking, `match?` |
| [clojure-test.md](references/clojure-test.md) | fixtures, running from the REPL, async bodies, JUnit output, a bespoke runner    |
| [runners.md](references/runners.md)           | choosing, adding, or configuring the cognitect runner or kaocha                  |
| [lazytest.md](references/lazytest.md)         | writing or running `describe`/`it` suites, contexts, watch mode                  |
| [test-check.md](references/test-check.md)     | properties, generators, `defspec`, shrinking, reproducing a seed                 |
| [failures.md](references/failures.md)         | a failing, erroring, or flaky test to diagnose                                   |

Files in this skill

  • LICENSE45.3 KB
  • NOTICE.md2.7 KB
  • SKILL.md7.2 KB
  • references/clojure-test.md4.4 KB
  • references/conventions.md3.1 KB
  • references/failures.md3.1 KB
  • references/lazytest.md4.6 KB
  • references/runners.md4.7 KB
  • references/test-check.md3.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.