# Testing
`deft/stdext/testing` is the programmatic test toolkit behind the
editor's Ctrl-T, AI "Generate Test", and the Tests panel. It discovers
test files, creates skeletons, and runs suites in-process through a
child runtime (no subprocess, no stdout parsing required).
import "deft/stdext/testing" as testing
## API
| Def | Signature | Description |
|---|---|---|
| `stem-of` | `{| path |}` | Basename with a trailing `.dft` stripped |
| `test-path-for` | `{| src-path |}` | `<dir>/<base>.dft` → `<dir>/test/test_<base>.dft` |
| `source-path-for` | `{| test-path |}` | Inverse mapping; nil when the basename lacks `test_` |
| `import-path-for` | `{| src-path |}` | Project-root-relative import path, no `.dft` |
| `ensure-skeleton!` | `{| src-path |}` | Create `test/` + a skeleton `defsuite` file; returns the test path |
| `suite-names` | `{| source-text |}` | `defsuite` names extracted from source |
| `run-all` | `{| test-path |}` | Run every suite in a fresh child runtime |
| `run-only` | `{| test-path filter |}` | Filtered run |
| `parse-results` | `{| stdout |}` | Parse `deft test` CLI stdout into `%{ statuses msgs summary }` |
The convention is `<dir>/<base>.dft` ↔ `<dir>/test/test_<base>.dft`.
## Result Shape
`run-all` / `run-only` return a structured map:
| Key | Value |
|---|---|
| `statuses` | `%{ "<suite>::<name>" :pass/:fail }` |
| `msgs` | failure messages keyed the same way |
| `summary` | `"N tests, P passed, F failed"` |
| `passed` / `failed` / `total` | counts |
| `status` | 1 when anything failed |
| `stdout` / `stderr` | rendered output lines |
| `results` | raw `test/results` vector |
## Example
# Editor Ctrl-T: open or create the test file def test-file [testing/test-path-for "src/parser.dft"] set skeleton [testing/ensure-skeleton! "src/parser.dft"] # Tests panel: run and inspect set res [testing/run-all $test-file] echo $res~summary echo [get $res~statuses "parser::parses refs"] set one [testing/run-only $test-file "parser::parses refs"]
## See Also
- Testing (manual) — `defsuite` / `deftest` / `assert/*` authoring
- Tests app help — the panel UI
- CLI — the `deft test` command