Skip to content

docs: add comprehensive rustdoc for testing module#230

Merged
joshrotenberg merged 2 commits intomainfrom
docs/testing-module-rustdoc
Jan 6, 2026
Merged

docs: add comprehensive rustdoc for testing module#230
joshrotenberg merged 2 commits intomainfrom
docs/testing-module-rustdoc

Conversation

@joshrotenberg
Copy link
Copy Markdown
Owner

@joshrotenberg joshrotenberg commented Jan 6, 2026

Summary

Adds detailed module-level documentation for the testing utilities with examples covering all features and common patterns.

Also includes a comprehensive example file (examples/testing_utilities.rs) that serves as both runnable tests and documentation.

Closes #224

Documentation Includes

Why Use This?

  • Automatic cleanup benefits
  • Panic-safe behavior
  • Debug-friendly options
  • Network support overview
  • Ready checks explanation

Configuration Options

  • Lifecycle Control: stop_on_drop, remove_on_drop
  • Debugging Failed Tests: keep_on_panic, capture_logs
  • Ready Checks: wait_for_ready (automatic or manual)
  • Container Reuse: reuse_if_running for faster local dev
  • Network Support: with_network, remove_network_on_drop
  • Fast Cleanup: stop_timeout configuration

Multi-Container Tests

  • ContainerGuardSet usage with shared networks
  • Coordinated startup and cleanup

Accessing Container Information

  • connection_string()
  • template()
  • container_id()
  • logs()
  • is_running()

Common Patterns

  • Reusable test fixtures
  • Unique container names for parallel tests
  • Manual cleanup when needed

Feature Flag Requirements

  • Shows how to enable the testing feature in Cargo.toml

Example File

Added examples/testing_utilities.rs with 10 runnable tests demonstrating:

  • Basic ContainerGuard usage with automatic cleanup
  • Connection strings for service access
  • Configuration options (stop timeout, debug mode, reuse)
  • ContainerGuardSet for multi-container tests
  • Container info access (logs, IDs)
  • Test fixture patterns

Run with: cargo test --example testing_utilities --features testing

Preview

The documentation renders beautifully in rustdoc with proper code highlighting and linked type references.

Adds detailed module-level documentation for the testing utilities
with examples covering all features and common patterns.

Documentation includes:
- Why use this module (benefits overview)
- Quick start example
- Configuration options:
  - Lifecycle control (stop/remove on drop)
  - Debugging failed tests (keep_on_panic, capture_logs)
  - Ready checks (wait_for_ready)
  - Container reuse for faster local dev
  - Network support
  - Fast cleanup with stop timeout
- Multi-container tests with ContainerGuardSet
- Accessing container information
- Common patterns:
  - Reusable test fixtures
  - Unique container names for parallel tests
  - Manual cleanup
- Feature flag requirements

Closes #224
Comprehensive example showing:
- Basic ContainerGuard usage with automatic cleanup
- Connection strings for service access
- Configuration options (stop timeout, debug mode, reuse)
- ContainerGuardSet for multi-container tests
- Container info access (logs, IDs)
- Test fixture patterns

All tests use unique ports for parallel safety.
@joshrotenberg joshrotenberg merged commit 216f814 into main Jan 6, 2026
11 checks passed
@joshrotenberg joshrotenberg deleted the docs/testing-module-rustdoc branch January 6, 2026 01:08
@github-actions github-actions Bot mentioned this pull request Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add comprehensive rustdoc for testing module

1 participant