// PART 10
Unit, integration, and UAT
This page shows the shape of each test type with the repository’s own conventions — what a unit test looks like here, how the integration crate is organized, and how a UAT run produces evidence.
Unit tests
Colocated, synchronous by default, test_ prefix:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parses_param_line() {
let line = r#"PARAM name AS string LIKE "John Smith" DESCRIPTION "Full name""#;
let parsed = parse_param(line).expect("test only");
assert_eq!(parsed.name, "name");
assert_eq!(parsed.type_name, "string");
}
#[tokio::test]
async fn test_resolves_user_scope() {
let scope = resolve(user_id).await;
assert!(scope.is_ok());
}
}
Repository-specific notes:
.expect()/unwrap()are acceptable in tests only — production code must not use them.- Keyword tests build a Rhai engine and assert on registration and evaluation
(
botbasic_*crates carry many such tests, including dedicated*_tests.rsmodules for multimodal and workflow DAG behavior). - The compiler crate (
botbasic_compiler/tests/) protects the syntax transforms — if you add a rewrite alias, add a case there.
Integration tests (bottest)
bottest/
├── tests/
│ ├── unit/ # cross-crate units
│ ├── integration/ # workflow suites, incl. tenant_isolation.rs
│ ├── e2e/ # end-to-end workflows
│ ├── fixtures/ # shared fixtures
│ ├── office_fidelity/ # document round-trips
│ ├── fuzz_regressions.rs
│ └── slo_budget_test.rs
cargo test -p bottest # everything
cargo test -p bottest --features integration tenant_isolation
The tenant isolation suite guards drive/CRM/product tenant scoping; it must stay green before touching any tenant/bucket/org-scoped handler. The SLO budget test and fuzz regressions run in the same crate — treat a failure there as a release blocker, not a flake.
UAT (browser-based)
All bot behavior is verified through the real UI over Chrome CDP — never via raw WebSocket scripts, which hide the frontend state the user actually sees.
1. Connect to the running Chrome (CDP 9222), open YOUR OWN tab
2. Navigate to the suite route (desktop shell, never the app HTML directly)
3. One action per script step: send → wait → read the reply → decide
4. Screenshot evidence → /tmp/opencode/uat<issue>_<case>.png
5. Finish with a per-criterion table (criterion | observed | PASS/FAIL)
Rules that keep UAT honest:
- One tab per active issue; recycle finished tabs; never close the browser.
- No polling loops or long sleeps inside a script; if it exceeds ~60 s, split the step.
- Never restart or rebuild the server from a UAT run — that is the driver’s job after a build completes.
- An issue closes only with per-criterion evidence attached (screenshots, command output, file:line).
What each layer must not do
| Layer | Must not |
|---|---|
| Unit | require a running server or network |
| Integration | mock the tenant scoping it is supposed to verify |
| UAT | batch many steps silently; claim PASS without a screenshot/output |
| Boteval | run outside CI |