type: testing title: Unit tests description: Overview of the in-module unit test suites in src/*.rs, what each one covers and how to run them. tags: [testing, cargo, unit-tests] verified:
651d1fb6c9
resource: repo://Cargo.toml1b05507d70
resource: repo://src/ai.rs9fec9d1af4
resource: repo://src/app.rs043e6252ba
resource: repo://src/autoreply.rs2a737474d8
resource: repo://src/config.rsce0c4ea8cd
resource: repo://src/history.rs6bddea306b
resource: repo://src/ui.rs7ea5eac45e
resource: repo://src/whatsapp.rs
generated: { by: "claude-code", at: "2026-10-19T18:58:46.219Z" }
---All tests are plain Rust unit tests in #[cfg(test)] mod tests blocks at the
bottom of each source file. There are no integration tests, no
[dev-dependencies] (Cargo.toml only has [dependencies]) and no test
touches the network or a real WhatsApp session.
cargo test # whole suite
cargo test autoreply:: # one module
cargo test should_reply_false # by name filter
| Module | Tests | Location | Covers |
|---|---|---|---|
autoreply |
41 | src/autoreply.rs:282+ |
private/self-chat detection, every ReplyGate::should_reply rule (disabled, own messages, non-private chats, backlog, blank/placeholder text, cooldown per chat), build_turns roles, context truncation, voice-note and image instructions |
config |
18 | src/config.rs:236+ |
defaults, trimming, multiline prompt, base URL normalisation, Debug masking, DB paths, BOM/CRLF, non-leaking parse errors, missing/invalid/unreadable files |
ai |
15 | src/ai.rs:320+ |
request and vision body shapes, image validation limits, Debug redaction, reply parsing, endpoint construction, truncation |
whatsapp |
21 | src/whatsapp.rs:945+ |
message rendering and placeholders, captions, image references, silent messages, JID device suffix, push-name filtering |
history |
11 | src/history.rs:392+ |
dedupe by message id, ordering and limits, chat name fallbacks, autoreply flags, contacts, on-disk open |
ui |
11 | src/ui.rs:508+ |
sender labels, clock time, QR text, wrapping, visible lines, input tail, title, selection clamp |
app |
10 | src/app.rs:762+ |
autoreply enable rules, vision applicability, error combining, selection and toggle helpers, AltGr handling |
Total: 127 #[test] functions.
History::open_in_memory() (only compiled for tests,
src/history.rs:75-81); the on-disk test writes under
std::env::temp_dir() in a per-process directory (src/history.rs:579-593).Pages with module details: AI autoreply, Configuration, AI client, WhatsApp client, History store, Terminal UI, Application state.