// CONTENTS Part 10 · Testing, quality, observability

// PART 10

Test strategy

Chapter 41 / 56 3 min read English Part 10 of 14

Testing is layered by what can break: units protect functions, crate tests protect behavior, the integration crate protects cross-crate workflows, and browser UAT protects what users actually see. Model evaluation (boteval) runs on CI only.

The layers

Layer Where Runs how
Unit tests inline #[cfg(test)] in every crate; tests/ dirs in botbasic_compiler, botbasic_data, botintegrations, botslides, botsources, botvibe cargo test -p <crate>
Binary-crate units botserver has no lib target cargo test -p botserver --bin botserver (plain -p botserver fails with “no library targets found”)
Integration bottest/ — tests/unit/, tests/integration/, tests/e2e/, fixtures, fuzz regressions, office fidelity, SLO budget tests cargo test -p bottest
Tenant isolation bottest/tests/integration/tenant_isolation.rs must stay green before touching tenant/bucket/org-scoped handlers
UAT browser-based, per issue Chrome CDP against the live app
Model evaluation boteval CI only — never locally; every task spends paid model calls

The commands

cargo test -p botcore                        # a library crate
cargo test -p botserver --bin botserver      # binary-crate unit tests
cargo test -p bottest                        # cross-crate integration
cargo test -p bottest --features integration tenant_isolation   # the isolation suite

Coverage goal: 80%+ on critical paths, with all error paths and all security guards tested (scripts/check_coverage.py is the gate).

Conventions

  • Test names use the test_ prefix; async tests use #[tokio::test].
  • Tests live with the code (inline modules) or in the crate’s tests/ dir — there is no separate test tree outside the crates.
  • Integration tests spawn the botserver binary as a process; they never link against it (the binary crate has no library target, and depending on it is a Cargo error).
  • Error-path tests are mandatory: the no-panic rule is only real if the error paths are exercised.
  • Security guards (SafeCommand, sql_guard, sanitizers, upload policy) have dedicated tests; a guard change without a test change is incomplete.

What is deliberately not tested locally

  • Boteval / model evaluation — CI-only (ci.yml → evaluate / boteval-run); results live in the CI run report. Never run it locally, never store run history in the repository.
  • Long-running UAT loops — browser automation is fragmented (one script = one action); a UAT run is a sequence of short steps with evidence, not a batch script.

Choosing where a test goes

The change is in… Test it in…
A keyword (botbasic_*) the keyword crate + compiler tests for syntax transforms
A route handler crate tests if the crate has them; else bottest integration
Schema / migration schema round-trip in the affected crate + a fresh-boot check
A tenant-scoped handler the tenant isolation suite (mandatory)
The chat pipeline bottest + a browser UAT of the affected dialog
Office documents round-trip bottest office fidelity tests

The gate order for a change

  1. rustfmt --emit stdout <file> (quick syntax check while builds run)
  2. cargo test -p <touched crate>
  3. cargo test -p bottest (or the isolation suite when tenants are touched)
  4. restart the server, run the targeted UAT in the browser
  5. commit split by area

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move