Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing Strategy

Status: Current Last updated: 2026-05-12 21:14 EDT

Unit tests

Each command module includes #[cfg(test)] unit tests that verify counting logic, edge cases, and output formatting against known inputs.

cargo nextest run -p talkbank-clan          # All tests (preferred)
cargo test -p talkbank-clan                 # Alternative
cargo test --doc -p talkbank-clan           # Doctests only (nextest can't run these)

Snapshot tests

Snapshot tests use insta to capture command output and detect regressions. They live alongside the test that produces them:

  • crates/talkbank-clan/tests/snapshots/: snapshots from transform_golden.rs, converter_golden.rs, and other top-level tests in the tests/ directory
  • crates/talkbank-clan/tests/clan_golden/snapshots/: snapshots produced by the clan_golden test module (paired @clan/@rust pairs)
cargo insta review -p talkbank-clan         # Review pending snapshot changes
cargo insta accept --all                    # Accept all pending changes

When you change a command’s output format, the snapshot test will fail. Review the diff to confirm the change is intentional, then accept.

Golden tests

Golden tests compare our output against legacy CLAN C binaries. See Golden Tests for details.

Running specific tests

# By name pattern
cargo nextest run -p talkbank-clan -E 'test(freq)'

# Only golden tests
cargo nextest run -p talkbank-clan -E 'test(golden)'

# Only indent tests
cargo nextest run -p talkbank-clan -E 'test(indent)'

Test fixtures

Test fixtures are real CHAT files from the reference corpus at corpus/reference/ (at the repo root). Never create ad hoc .cha test files, use existing corpus files or ask for new ones to be added to the reference corpus.

Current test counts

The talkbank-clan suite spans unit, snapshot, golden, and integration tests. The absolute count moves as commands are added or extended; get the live number with:

cargo nextest list -p talkbank-clan

The last line of the summary is the total count.