Testing Architecture π‘ BETA
The test architecture is a workspace of unit, integration and browser suites that share the bottest harness.
Overview
Tests are split by the boundary they cross. Unit tests sit beside the code they exercise; integration tests live under bottest/tests/integration/; end-to-end suites live under bottest/tests/e2e/. The bottest crate supplies the shared harness, mocks and fixtures.
Architecture Diagram
| Component | Role in the test architecture |
|---|---|
bottest |
Harness, CLI driver, mocks (LLM, Zitadel, Teams, WhatsApp), fixtures and suites |
botschema |
Single source of Diesel table! definitions used by database tests |
botserver |
Binary under test; its unit tests need --bin botserver |
botui |
Static suite served on port 3000, exercised through Chrome DevTools Protocol |
ci.yml |
Runs guards, unit-policy checks and platform jobs on every push and pull request |
Test Layers
| Layer | Location | Command |
|---|---|---|
| Unit | Inline #[cfg(test)] modules and bottest/tests/unit/ |
cargo test -p <crate> --lib |
| Integration | bottest/tests/integration/ (feature integration) |
cargo test -p bottest --features integration tenant_isolation |
| End-to-end | bottest/tests/e2e/ (feature e2e) |
cargo test -p bottest --features e2e |
bottest declares default = ["full"], where full enables both integration and e2e (its Cargo.toml).
Test Harness
The harness starts services, resolves ports, exposes a bot runner and a conversation helper, and writes evidence. Service modules cover PostgreSQL, Valkey, OtterIO and a browser service. Mocks replace the LLM and identity providers so suites run without paid model calls.
Temporary Stack Architecture
Each run builds an isolated stack with its own ports and data directories. The harness owns the lifecycle: start, run, collect evidence, stop. No suite writes into the developer stack.
Isolation Strategy
| Boundary | Mechanism |
|---|---|
| Service | Dedicated ports and processes per run (bottest/src/ports.rs) |
| Network | Mock servers stand in for external providers |
| Data | Per-run databases and buckets; fixtures recreated for each case |
| Tenants | tenant_isolation suite checks that org, bucket and project scopes never cross |
Test Execution Flow
- Parse the suite selection and start the harness.
- Start the services the selected suite needs.
- Seed fixtures through the harness.
- Run each case; capture logs and browser evidence.
- Stop the stack and report pass/fail with saved evidence.
Browser Automation
The bottest crate uses chromiumoxide and Chrome DevTools Protocol directly; it does not depend on a WebDriver binary. Browser suites open the desktop shell route, not individual suite HTML fragments (root AGENTS.md, "Suite Apps β ALWAYS Open Inside Desktop").
Error Handling
A failure is captured as evidence, not swallowed. Production code may not use unwrap, expect or panic!; the same rule applies to harness helpers that run inside server processes (root AGENTS.md, Security Directives).
Performance Considerations
Run crates one at a time: the full workspace dependency graph does not fit the 4.5 GiB development container. Start long checks in the background and keep working while they run (root AGENTS.md, Error Fixing Workflow).
CI/CD Integration
.github/workflows/ci.yml runs the guard, i18n, security and unit-policy jobs on pushes and pull requests. The Forgejo runner executes the same repository jobs on the self-hosted ALM instance. BotBook reference pages are regenerated by the gen_*.py scripts, not edited by hand.
Best Practices
- Name tests
test_and keep them close to the code they cover. - Prefer deterministic mocks over live providers; never call a paid model in a local test.
- Keep each test independent of ordering and of the developer stack.
- Re-run the tenant isolation suite after touching any tenant, bucket or org scoped handler.
Debugging
Read the harness output first, then botserver.log and botui.log. Client-side errors are logged with a CLIENT: prefix. Stop when an error appears: identify and fix the root cause before continuing.
Future Enhancements
Plans and roadmap items live as GitHub issues, not in documentation. This page describes the suites that exist in the tree today.
References
Authority: bottest/Cargo.toml (features and test targets), bottest/src/ (harness and services), .github/workflows/ci.yml, and root AGENTS.md (Testing Strategy, Debugging Rules).
Limits
cargo test -p botserverhas no library target and tests nothing; usecargo test -p botserver --bin botserver.- The
e2eandintegrationfeatures are separate; enabling one does not enable the other unlessfullis used. - Boteval runs on CI only. No local command in this chapter spends model calls.
- No suite may restart
botserveron behalf of a contributor; only the driver restarts services after a build.
Related
- CI/CD Integration β where the jobs run.
- End-to-End Testing β browser suites in detail.
- Testing β unit and integration practice.
- Chapter 12: Ecosystem & Reference