Chicago TDD Tools
Rust testing framework enforcing Chicago-style TDD (Classicist Test-Driven Development) through compile-time guarantees.
If it compiles, correctness follows. Type system encodes invariants. Quality is the default, not an afterthought.
Why Chicago TDD?
Chicago-style TDD (Classicist approach) focuses on behavior verification using real collaborators instead of mocks. This framework enforces that philosophy through Rust's type system:
- Type-First Design: Compiler prevents invalid test states before runtime. State machines encoded at type level—if your test compiles, the AAA (Arrange-Act-Assert) pattern is enforced.
- Error Prevention (Poka-Yoke): Mistakes caught at compile time, not in CI. No
.unwrap()in production code. Nopanic!(). Git hooks prevent them from being committed. - Zero-Cost Abstractions: All safety guarantees compiled away—performance equals unsafe manual code.
- 80/20 Focus: Framework solves 80% of testing problems with 20% extra effort via generics, const generics, and macros.
Result: Tests that actually verify behavior. Bugs prevented before code review. Production panic rate: ~zero.
Quick Start (Choose Your Path)
1️⃣ First Time User? → 5-Minute Setup
# Install cargo-make (required)
# Create test file: tests/my_first_test.rs
# Run tests
✓ Installation complete when cargo make test shows 3 passing tests.
2️⃣ Just Want Examples? → Examples Directory
# Browse working examples (18 included, all tested)
# Run a specific example
📖 Complete examples guide: See examples/README.md for all 18 examples organized by category.
3️⃣ Need Full Reference? → API Documentation
4️⃣ Using Docker/Containers? → Integration Guide
See Integration Testing section below.
5️⃣ Testing Observability/OTEL? → Weaver Setup
See Observability & Weaver section below.
Core Capabilities (With Real Examples)
1. Essential Testing Macros
Synchronous tests (no async runtime needed):
use *;
test!;
Async tests (1s default timeout):
async_test!;
Fixture-based tests (automatic setup/teardown):
fixture_test!;
Performance tests (tick budget validation):
performance_test!;
2. Advanced Assertion Helpers
Result type assertions:
test!;
3. Fail-Fast Verification (v1.4.0)
Zero-tolerance execution context with 12-phase verification pipeline:
use *;
test!;
Key features:
- 47 invariant violations covering all failure modes
- 12 distinct phases from Contract Definition to Quality Dashboard
- Self-validating receipts with version and checksum
- No degradation, no warnings ignored, no partial success
📖 Example: See examples/fail_fast_verification.rs
4. Sector-Grade Reference Stacks (v1.4.0)
Production-grade implementations demonstrating the Chatman Equation in real-world workflows:
use *;
test!;
Available sectors:
- Academic Publishing: Paper review lifecycle with deterministic decision algorithms
- Enterprise Claims: Insurance claims processing with fraud detection and settlement
📖 Example: See examples/sector_stacks_workflows.rs
5. RDF-Driven Validation (v1.4.0)
Ontologies as single source of truth for workflow validation:
use *;
test!;
📖 Example: See examples/rdf_validation.rs
6. Swarm Coordination (v1.4.0)
Distributed multi-sector coordination with task receipts:
use *;
test!;
📖 Example: See examples/swarm_coordination.rs
7. Property-Based Testing
Generate random test data and verify properties hold for all inputs:
use *;
test!;
With proptest (requires property-testing feature):
test!;
When to use: Edge cases are hard to imagine. Random generation finds them automatically.
8. Mutation Testing
Verify test quality by intentionally breaking code and checking tests catch it:
use *;
use HashMap;
test!;
Mutation operators: RemoveKey, AddKey, ChangeValue, NegateCondition
Target: ≥80% mutation score indicates thorough test coverage.
9. Snapshot Testing
Verify complex outputs (JSON, HTML, serialized data) don't change unexpectedly:
test!;
Snapshot management:
10. Concurrency Testing
Detect race conditions with deterministic thread-safe testing:
test!;
11. CLI Testing
Test command-line interfaces like they're black boxes:
test!;
Integration Testing
Docker + Testcontainers
Test with real services (Postgres, Redis, etc.) without manual Docker commands:
fixture_test!;
Enable with:
[]
= { = "../chicago-tdd-tools", = ["testcontainers"] }
Run with:
Observability & Weaver
Test OpenTelemetry (OTEL) instrumentation and semantic convention compliance with Weaver live-check.
1. Bootstrap Weaver (First Time)
# Download Weaver CLI + semantic convention registry
# This creates:
# - target/<profile>/weaver (executable)
# - registry/ (semantic conventions)
2. Quick Smoke Test (No Docker Required)
# Verify Weaver works + send test span
# Output: Weaver version + telemetry validation
3. OTEL Span Validation
use *;
test!;
4. Weaver Live-Check (Full Validation)
Validates spans/metrics against OpenTelemetry semantic conventions in real-time:
fixture_test!;
Enable with:
[]
= {
path = "../chicago-tdd-tools",
= ["weaver", "otel"] # otel auto-enabled with weaver
}
Run integration tests:
# Or skip if Docker unavailable:
WEAVER_ALLOW_SKIP=1
Build System (Important!)
⚠️ Always use cargo make, never raw cargo:
Why mandatory?
- Handles proc-macro crates correctly
- Enforces timeouts (prevents hanging)
- Consistent build environment
- Single source of truth for build process
Essential for safety:
Quality Standards (Poka-Yoke Enforcement)
Compile-Time Prevention
Type-level AAA enforcement: If test compiles, AAA pattern is correct.
Sealed traits: Can't create invalid test states.
Const assertions: Size and alignment checked at compile time.
Build-Time Prevention
Git hooks: Prevent .unwrap(), .expect(), panic!() from being committed.
Clippy enforcement: All warnings treated as errors (-D warnings).
Timeout SLAs enforced:
- Quick checks: 5s (fmt, check)
- Compilation: 5-30s depending on profile
- Lint: 300s (CI cold-start)
- Unit tests: 1s per test
- Integration tests: 30s with Docker
- Coverage: 30s
Runtime Safety
Result-based errors: No panics in production code.
// ❌ Never in production
let value = result.unwrap;
// ✅ Always do this
let value = result?; // Propagate errors
// OR
let value = match result ;
Alert macros for structured logging:
alert_critical!; // 🚨 Must stop
alert_warning!; // ⚠️ Should stop
alert_info!; // ℹ️ Informational
alert_success!; // ✅ Success
alert_debug!; // 🔍 Diagnostics
Risk Reduction (FMEA)
| Risk | Original | Current | Mitigation |
|---|---|---|---|
| Production panics (unwrap/expect) | RPN 180 | RPN 36 | Git hooks, CI checks, lint deny |
| Tests pass locally, fail CI | RPN 105 | RPN 21 | Multi-OS, pre-commit simulation |
| Clippy warnings accumulate | RPN 112 | RPN 11 | CI enforcement, pre-commit |
| Flaky tests | RPN 120 | RPN 24 | Retry logic (3x), test isolation |
| Coverage regressions | RPN 336 | RPN 67 | Coverage tracking, Codecov |
Feature Flags
Core (always available): test!, async_test!, fixture_test!, builders, assertions
Enable as needed:
[]
= {
path = "../chicago-tdd-tools",
= [
"testing-extras", # property-testing + snapshot-testing + fake data (most common)
"otel", # OpenTelemetry span/metric validation
"weaver", # Weaver semantic convention live-check (implies otel)
"testcontainers", # Docker container support
"async", # Async fixture providers (Rust 1.75+)
]
}
Recommended bundles:
- 80% use case:
["testing-extras"](property + snapshot + fake data) - Full testing:
["testing-extras", "testcontainers"] - With observability:
["testing-extras", "otel", "weaver"] - Everything:
["testing-extras", "otel", "weaver", "testcontainers", "async"]
Documentation Portal
📚 Learning Path (Start Here)
- Getting Started - Installation, first test, troubleshooting
- Quick Guide - Essential patterns (80% of use cases, 15 min read)
- User Guide - Comprehensive usage (deep dive, 1 hour)
🔧 How-to Guides (Solve Specific Problems)
- Weaver Live-Check - Full OTEL + Weaver setup
- CLI Testing Guide - Test command-line tools
- Observability Testing - OTEL testing patterns
- Timeout Enforcement - Custom timeout SLAs
📖 Reference (Lookup Technical Details)
- API Reference - Complete API documentation
- Architecture - Design principles, module organization
- SLA Reference - Service level agreements, quality standards
🎓 Understanding (Deep Dives)
- SPR Guide - Elite Rust standards, best practices
- Code Review Checklist - What reviewers look for
- FMEA: Tests, Build, Actions - Risk analysis, improvements
- Test Isolation Guide - Preventing test interdependencies
- Pattern Cookbook - Alexander-style patterns (20 documented)
🔍 Troubleshooting
Problem: "command not found: cargo-make"
- Fix:
cargo install cargo-make
Problem: "cannot find macro 'test!'"
- Fix: Add
use chicago_tdd_tools::prelude::*;to your test file
Problem: "feature 'X' is required for module Y"
- Fix: Enable feature in
Cargo.toml:features = ["feature-name"]
Problem: Tests pass locally but fail in CI
- Fix: Run
cargo make ci-localto simulate CI environment
More help: See Getting Started - Troubleshooting
Examples
18 complete, runnable examples are included, all with tests. Browse them:
# List examples
# Run an example
📖 Complete examples guide: See examples/README.md for full documentation.
Example categories:
Tutorials (Learning-oriented):
basic_test.rs- Fixtures, builders, assertionsmacro_examples.rs- Test/assertion macrossector_stacks_workflows.rs- Production-grade workflows (v1.4.0)
How-To Guides (Task-oriented):
property_testing.rs- Random test generation, propertiesmutation_testing.rs- Test quality validationsnapshot_testing.rs- Output comparison (enhanced in v1.4.0)concurrency_testing.rs- Thread safety with loomcli_testing.rs- Command-line testingtestcontainers_example.rs- Docker integrationotel_weaver_testing.rs- Observability testingfail_fast_verification.rs- 12-phase verification pipeline (v1.4.0)rdf_validation.rs- RDF-driven validation (v1.4.0)swarm_coordination.rs- Distributed coordination (v1.4.0)
Explanation (Understanding-oriented):
go_extra_mile.rs- 1st/2nd/3rd idea progression, 80/20 thinkingadvanced_features.rs- Type-level guarantees, zero-cost abstractions
Reference:
operator_registry.rs- Pattern registration and guard system (v1.4.0)all_phases_pipeline.rs- Complete 12-phase pipeline demonstrationhyper_advanced_microkernel.rs- Hyper-advanced μ-kernel features
Requirements
| Component | Minimum | Verify | Install |
|---|---|---|---|
| Rust | 1.70 | rustc --version |
rustup |
| Cargo | Latest stable | cargo --version |
Included with Rust |
| cargo-make | Latest | cargo make --version |
cargo install cargo-make |
| Tokio | 1.0+ | (add to Cargo.toml) | tokio |
| Docker* | Latest | docker ps |
Docker Desktop |
| Rust 1.75+* | For async fixtures | rustc --version |
rustup update stable |
* Optional—only needed for specific features (Docker, async fixtures)
Contributing & Community
- Issues/Questions: GitHub Issues
- Documentation Feedback: Create issue with
[docs]tag - Code Contributions: Follow Code Review Checklist
License
MIT
Quick Commands Reference
# Development
# Testing
# Observability
# Code Quality
# Build
What's New in v1.4.0
Production-Grade Verification Infrastructure:
- 🛡️ Fail-Fast Hardening - 47 invariant violations, zero-tolerance execution
- 📊 12-Phase Verification Pipeline - Complete end-to-end verification
- 🏭 Sector-Grade Reference Stacks - Academic publishing & claims processing workflows
- 🔗 RDF Integration - Ontologies as single source of truth
- 📋 Operator Registry - Global pattern registration with guard system
- 🐝 Swarm Protocol - Distributed multi-sector coordination
- 📸 Enhanced Snapshot Testing - Better fixtures and organization
100% backward compatible with v1.3.0. Upgrade with confidence.
📖 Documentation:
- Release Notes - Complete feature documentation
- GitHub Release - GitHub release notes
- Changelog - Full change history
- Release Checklist - Pre-release verification
Next Step: Follow the Quick Start path that matches your need, or jump to Learning Path for structured learning.
Questions? See Troubleshooting or check Getting Started.