Chicago TDD Tools
Testing framework for Chicago TDD (Classicist Test-Driven Development) in Rust. Enforces AAA pattern, provides fixtures, builders, and advanced testing capabilities.
Development Workflow
Pre-commit validation (run before committing):
Important: The CI/CD pipeline automatically enforces clippy checks on every commit/PR.
Always run cargo make pre-commit before committing to catch issues early.
Clippy standards:
- All clippy warnings are treated as errors (
-D warnings) - Use
#[allow(clippy::...)]with justification comments when necessary - CI/CD pipeline will fail if clippy finds any warnings/errors
- See SPR Guide for clippy best practices
Quick Start
Step 1: Install cargo-make (required for build system):
Verify: cargo make --version should show version. If you get "command not found", install cargo-make first.
Step 1.5: Install Git hooks (recommended for production code safety):
This installs pre-commit hooks that prevent .unwrap() and .expect() in production code, reducing production panics.
Step 2: Create a new Rust project (if you don't have one):
Step 3: Add dependency to Cargo.toml:
For local development (if framework is in parent directory):
[]
= "my-project"
= "0.1.0"
= "2021" # Required: Edition 2021
[]
= { = "../chicago-tdd-tools" }
= { = "1.0", = ["rt", "macros"] }
For GitHub users (when framework is published to crates.io):
[]
= "my-project"
= "0.1.0"
= "2021" # Required: Edition 2021
[]
= "1.1.2" # Use version when published
= { = "1.0", = ["rt", "macros"] }
Step 4: Create your first test file tests/my_first_test.rs:
use *; // prelude::* imports all common macros and types
test!;
async_test!;
fixture_test!;
Step 5: Verify installation and run tests:
Verify Installation:
- ✅ Compilation succeeds:
cargo make checkcompletes without errors - ✅ Tests run:
cargo make testshows your tests passing - ✅ Macros work: Test file compiles and runs successfully
Note: Always use cargo make commands (not cargo test directly). The build system handles proc-macro crates and includes timeouts.
Core Macros
Test Macros
test!: Synchronous tests with AAA patternasync_test!: Async tests (1s timeout)fixture_test!: Async tests with automatic fixture setup
Assertion Macros
assert_ok!: Assert Result is Okassert_err!: Assert Result is Errassert_in_range!: Assert value in range
See Quick Guide for complete macro reference.
Features
Most Common: Enable testing-extras for property-based testing, snapshot testing, and fake data:
[]
= {
path = "../chicago-tdd-tools", # Or use git URL when published
= ["testing-extras"] # Enable common testing features
}
When to use features: Enable features only when you need them (e.g., testcontainers for Docker integration, otel for observability testing).
See Getting Started for complete feature list (property-testing, mutation-testing, testcontainers, otel, weaver, etc.)
Weaver Live-Check Quick Start
Chicago TDD Tools dogfoods Weaver. Follow these steps to exercise live-check locally:
Prerequisites
- Weaver feature: Enable
weaverfeature inCargo.toml(automatically enablesotel) - Docker (for integration tests only): Required for
cargo make test-integration- Verify Docker is running:
docker psshould succeed - Install: Docker Desktop if not installed
- Verify Docker is running:
Setup Steps
-
Bootstrap prerequisites (Weaver CLI + semantic convention registry):
- Downloads Weaver binary to
target/<profile>/weaver - Clones semantic convention registry to
registry/ - Takes ~30-60 seconds on first run
- Downloads Weaver binary to
-
Run the fast smoke test (version check + telemetry span):
- Verifies Weaver CLI is installed and working
- Sends a test telemetry span
- Does not require Docker
- Should complete in <5 seconds
-
Run full integration when Docker is available:
- Runs container-based Weaver integration tests
- Requires Docker daemon running
- Requires
weaverfeature enabled - Tests fail fast if prerequisites missing (unless
WEAVER_ALLOW_SKIP=1is set)
Need to temporarily skip Weaver tests? Set WEAVER_ALLOW_SKIP=1 in your environment. Without that explicit opt-out, Weaver tests fail fast when prerequisites are missing—quality is the default.
Build System
Always use cargo make commands (required for proc-macro crates and timeout enforcement):
Why cargo-make? The build system handles proc-macro crates correctly, includes timeouts to prevent hanging, and ensures consistency. Using cargo test directly may fail with proc-macro errors.
Documentation
- Quick Guide - Essential patterns (80% of use cases)
- Getting Started - Complete setup guide with troubleshooting
- User Guide - Comprehensive usage guide
- API Reference - Complete API documentation
- Architecture - Design principles
- Pattern Cookbook - Alexander-style pattern language (testing, architecture, design)
- Documentation Index - Complete documentation navigation
Requirements
Prerequisites Checklist
Required:
- Rust: Edition 2021 (Rust 1.70+)
- Verify: Run
rustc --version- should show 1.70.0 or higher - Install: Use rustup if not installed
- Verify: Run
- Cargo: Latest stable (comes with Rust)
- Verify: Run
cargo --version- should show latest stable
- Verify: Run
- cargo-make: Required for build system
- Install:
cargo install cargo-make - Verify: Run
cargo make --version- should show version number - If missing: Install with
cargo install cargo-make, then verify
- Install:
- Tokio: Required for async tests (add to
dev-dependenciesin yourCargo.toml)
Optional (enable features as needed):
- Docker: Required for
testcontainersfeature- Verify: Run
docker ps- should show Docker daemon running - Install: Docker Desktop for your platform
- Verify: Run
- Rust 1.75+: Required for
asyncfeature (async fixture providers)- Verify: Run
rustc --version- should show 1.75.0 or higher - Upgrade: Run
rustup update stableif needed
- Verify: Run
Troubleshooting
Common Setup Errors
"command not found: cargo-make"
- Cause: cargo-make not installed or not in PATH
- Fix: Install with
cargo install cargo-make, then verify withcargo make --version - Verify: Command should show version number, not "command not found"
"cannot find crate 'chicago_tdd_tools'"
- Cause: Path incorrect, edition missing, or dependency not added
- Fix:
- Check
Cargo.tomlhasedition = "2021"in[package]section - Verify path in
[dev-dependencies]is correct (e.g.,path = "../chicago-tdd-tools") - Ensure dependency is in
[dev-dependencies], not[dependencies]
- Check
- Verify: Run
cargo make check- should compile without errors
"cannot find macro 'test!'"
- Cause: Missing prelude import
- Fix: Add
use chicago_tdd_tools::prelude::*;at the top of your test file - Alternative: Use explicit import:
use chicago_tdd_tools::test; - Verify: Test file should compile after adding import
"edition 2021 required"
- Cause:
Cargo.tomlmissing edition specification - Fix: Add
edition = "2021"to[package]section inCargo.toml:[] = "my-project" = "0.1.0" = "2021" # Required
"feature 'X' is required for module Y"
- Cause: Feature flag not enabled for feature-gated module
- Fix: Enable required feature in
Cargo.toml:= { path = "../chicago-tdd-tools", = ["feature-name"] # e.g., "otel", "weaver", "testcontainers" } - Common features:
testing-extras,testcontainers,otel,weaver,async
"cannot find module 'observability'" or "cannot find module 'integration'"
- Cause: Feature-gated modules require explicit feature flags
- Fix: Enable required features:
features = ["otel", "weaver", "testcontainers"]
Tests pass locally but fail in CI
- Cause: Environment differences (missing dependencies, different Rust version)
- Fix:
- Verify Rust version matches:
rustc --version - Run
cargo make ci-localto simulate CI environment - Check all prerequisites are installed (cargo-make, Docker if needed)
- Verify Rust version matches:
Docker/Testcontainers tests fail
- Cause: Docker daemon not running or not available
- Fix:
- Start Docker Desktop
- Verify with
docker ps- should show running containers or empty list (not error) - Ensure Docker is accessible:
docker infoshould succeed
Weaver tests fail
- Cause: Weaver CLI not installed or registry not bootstrapped
- Fix:
- Run
cargo make weaver-bootstrapto install Weaver CLI and registry - Verify with
cargo make weaver-smoke- should pass - If Docker required: Ensure Docker is running for integration tests
- Run
See Getting Started - Troubleshooting for more detailed help.
License
MIT