Agentic Testing
Framework
- mini.test with Busted-style emulation.
- Test files live next to source files as
<module>.test.lua.
tests/ holds the runner, helpers, functional tests, and integration tests.
- The previous Busted/lazy.nvim setup is gone.
TDD
For every bug fix or behavioral change:
- Bootstrap missing symbols first so the test loads.
- Write the failing assertion.
- Run the focused test with
make test-file FILE=<path> and confirm it fails
for behavior, not setup:
- wrong: missing module, nil method, syntax error, unresolved import
- right: value/state/output mismatch
- Implement the minimum code to pass.
- Re-run
make test-file FILE=<path>.
- Run the relevant full check.
- After adding or changing tests, reconcile the case count. This guards against
silently dropped OR unexpectedly generated tests. Both are failures.
- Compute EXPECTED cases by reading the file, not grepping:
- each static
it() = 1 case
- each
it() inside a for/each/table-driven loop = the loop's
iteration count (a single it( line can emit many cases, or zero)
- a grep of
it( is a lower bound, never the answer
- Read ACTUAL from
Total number of cases: N in the
make test-file FILE=<path> output.
- EXPECTED MUST equal ACTUAL. Mismatch = a test was dropped, a loop is empty,
or a generator misfired; stop and reconcile before claiming green.
Eyeballing ACTUAL alone is NOT the check - you must derive EXPECTED first.
Pure refactors, formatting, and docs can skip red/green, but say that in the PR.
Commands
make test
make test-file FILE=lua/agentic/acp/agent_modes.test.lua
Use make test-file FILE=<path> for the red/green inner loop; it runs one file
in seconds. Never run make validate between iterations. After all .lua
edits, run make validate and fix until it passes - the task is not done until
it does. Pre-commit gate, not a per-test step.
For Lua or test changes, root AGENTS.md requires make validate after the
focused checks.
Before writing assertions
Read the exact helper APIs before using them:
tests/helpers/assert.lua
tests/helpers/spy.lua
tests/helpers/child.lua when using child Neovim tests
Load references only when needed:
references/assert-spy.md: custom assert, spy, and stub API details.
references/child-nvim.md: child process tests and RPC helpers.
references/async-tests.md: scheduled/deferred code and mark-count traps.
Defaults
- Unit tests: co-located
<module>.test.lua.
- Integration or functional tests:
tests/integration/ or tests/functional/
when behavior spans modules or needs real editor state.
- ACP or transport-touching tests must stub
agentic.acp.acp_transport or any
dependency that opens subprocesses or network calls.
- Tests run sequentially in one Neovim process unless you explicitly use
tests.helpers.child.
- Clean up buffers, windows, autocommands, globals, stubs, and spies.
1---2name: agentic-testing3description: MANDATORY before creating, editing, or reviewing tests in agentic.nvim, and before behavior changes that require TDD. Covers mini.test workflow, red/green rules, commands, mark-count checks, and which test references to load.4---56# Agentic Testing78## Framework910- mini.test with Busted-style emulation.11- Test files live next to source files as `<module>.test.lua`.12- `tests/` holds the runner, helpers, functional tests, and integration tests.13- The previous Busted/lazy.nvim setup is gone.1415## TDD1617For every bug fix or behavioral change:18191. Bootstrap missing symbols first so the test loads.202. Write the failing assertion.213. Run the focused test with `make test-file FILE=<path>` and confirm it fails22 for behavior, not setup:23 1. wrong: missing module, nil method, syntax error, unresolved import24 2. right: value/state/output mismatch254. Implement the minimum code to pass.265. Re-run `make test-file FILE=<path>`.276. Run the relevant full check.287. After adding or changing tests, reconcile the case count. This guards against29 silently dropped OR unexpectedly generated tests. Both are failures.30 1. Compute EXPECTED cases by reading the file, not grepping:31 - each static `it()` = 1 case32 - each `it()` inside a `for`/`each`/table-driven loop = the loop's33 iteration count (a single `it(` line can emit many cases, or zero)34 - a grep of `it(` is a lower bound, never the answer35 2. Read ACTUAL from `Total number of cases: N` in the36 `make test-file FILE=<path>` output.37 3. EXPECTED MUST equal ACTUAL. Mismatch = a test was dropped, a loop is empty,38 or a generator misfired; stop and reconcile before claiming green.39 Eyeballing ACTUAL alone is NOT the check - you must derive EXPECTED first.4041Pure refactors, formatting, and docs can skip red/green, but say that in the PR.4243## Commands4445```bash46make test47```4849```bash50make test-file FILE=lua/agentic/acp/agent_modes.test.lua51```5253Use `make test-file FILE=<path>` for the red/green inner loop; it runs one file54in seconds. Never run `make validate` between iterations. After all `.lua`55edits, run `make validate` and fix until it passes - the task is not done until56it does. Pre-commit gate, not a per-test step.5758For Lua or test changes, root `AGENTS.md` requires `make validate` after the59focused checks.6061## Before writing assertions6263Read the exact helper APIs before using them:6465- `tests/helpers/assert.lua`66- `tests/helpers/spy.lua`67- `tests/helpers/child.lua` when using child Neovim tests6869Load references only when needed:7071- `references/assert-spy.md`: custom assert, spy, and stub API details.72- `references/child-nvim.md`: child process tests and RPC helpers.73- `references/async-tests.md`: scheduled/deferred code and mark-count traps.7475## Defaults7677- Unit tests: co-located `<module>.test.lua`.78- Integration or functional tests: `tests/integration/` or `tests/functional/`79 when behavior spans modules or needs real editor state.80- ACP or transport-touching tests must stub `agentic.acp.acp_transport` or any81 dependency that opens subprocesses or network calls.82- Tests run sequentially in one Neovim process unless you explicitly use83 `tests.helpers.child`.84- Clean up buffers, windows, autocommands, globals, stubs, and spies.