Expand description
§Reinhardt Test
Testing utilities for the Reinhardt framework.
§Overview
This crate provides comprehensive testing tools inspired by Django REST Framework, including API clients, request factories, assertions, and TestContainers integration for database testing.
Most functionality is provided by reinhardt-testkit. This crate adds testing
utilities that depend on functional crates (reinhardt-auth, reinhardt-admin,
reinhardt-pages, reinhardt-tasks).
§Features
APIClient: HTTP client for making test API requestsAPIRequestFactory: Factory for creating mock HTTP requestsAPITestCase: Base test case with common assertions- Response Assertions: Status, header, and body assertions
Factory: Model factory for generating test dataDebugToolbar: Debug panel for inspecting queries and timingWebSocketTestClient: WebSocket connection testing- TestContainers: Database containers (PostgreSQL, MySQL, Redis) integration
§Feature Flags
testcontainers: Enable TestContainers for database testingstatic: Enable static file testing utilitieswasm: Enable WASM frontend testing utilitieswasm-full: Enable WASM testing with full web-sys featuresserver-fn-test: Enable server function testing utilitiestasks: Enable task queue testing utilitiesadmin: Enable admin panel testing utilitiese2e: Enable E2E browser testing utilities via fantoccini/WebDriver
Re-exports§
pub use reinhardt_testkit::reinhardt_urls;
Modules§
- assertions
- Assertion helpers for common test patterns. Additional assertion helpers for testing
- client
- HTTP client for making test API requests. API Client for testing
- debug
- Debug toolbar for inspecting queries, timing, and cache.
- factory
- API request factory for creating mock HTTP requests. Request factory for creating test requests
- fixtures
- Test fixtures and utilities for Reinhardt framework testing
- http
- HTTP request/response helpers for testing. HTTP test utilities for Reinhardt framework
- logging
- Test logging initialization utilities. Test logging utilities for Reinhardt framework
- mock
- Mock function and spy utilities for testing.
- prelude
- Re-export commonly used testing types
- resource
- Test resource lifecycle management (setup/teardown). Test resource management with automatic setup and teardown
- response
- Response wrapper with assertion methods. Test response wrapper with assertion helpers
- server
- Test server spawning and management. HTTP server test utilities
- testcase
- Base test case with common assertions. Base test case with common setup and assertions
- views
- Test view implementations for integration testing. View test utilities for Reinhardt framework
- websocket
- WebSocket testing client. WebSocket test client and utilities for integration testing
Macros§
- impl_
test_ model - Helper macro for implementing Model trait with empty Fields for test models
Structs§
- APIClient
- Test client for making API requests
- APIClient
Builder - Builder for creating APIClient with custom configuration
- APIRequest
Factory - Factory for creating test requests
- APITest
Case - Base test case for API testing
- ApiTest
Model - Test model for API view tests
- Async
Teardown Guard - RAII guard for async test resource cleanup using async-dropper
- Body
Echo Handler - Test handler that echoes the request body
- Call
Record - Call record for tracking function calls
- Debug
Panel - Debug panel information
- Debug
Toolbar - Debug toolbar
- Delayed
Handler - Test handler with configurable delay
- Echo
Path Handler - Simple test handler that echoes the request path
- Error
Test View - Create a view that always returns an error for testing error handling
- Factory
Builder - Simple factory builder
- Fixture
Loader - Fixture data loader
- Large
Response Handler - Test handler that returns a large response
- Method
Echo Handler - Test handler that echoes the request method
- Mock
Function - Mock function tracker
- Request
Builder - Builder for constructing test requests
- Router
Handler - Test handler that returns different responses based on path
- Server
Router - Unified router with hierarchical routing support
- Simple
Handler - Simple handler wrapper for testing
- Simple
Test View - Create a simple view for testing basic functionality
- Spy
- Spy for tracking method calls with arguments
- SqlQuery
- SQL query record
- Status
Code Handler - Test handler that returns specific status codes based on path
- Suite
Guard - Guard for suite-wide shared resource
- Teardown
Guard - RAII guard for automatic test resource cleanup
- Test
Model - Test model for view tests
- Test
Response - Test response wrapper
- Timing
Info - Request/Response timing information
- WebSocket
Test Client - WebSocket test client for integration testing
Enums§
- Client
Error - Errors that can occur when using the API test client.
- Debug
Entry - A single entry within a debug panel.
- Error
Kind - Kind of error that an
ErrorTestViewwill produce. - Fixture
Error - Errors that can occur during fixture loading.
- Http
Version - HTTP version configuration for APIClient
Traits§
- Async
Test Resource - Async version of TestResource for async setup/teardown
- Factory
- Factory trait for creating test data
- Response
Ext - Extension trait for Response assertions
- Suite
Resource - Suite-wide shared resource (BeforeAll/AfterAll pattern)
- Test
Resource - Per-test resource with setup and teardown hooks
Functions§
- acquire_
suite - Acquire suite-wide shared resource
- api_
client_ from_ url - Create an APIClient from a server URL string
- assert_
has_ header - Assert response has header
- assert_
header_ contains - Assert header contains substring
- assert_
header_ equals - Assert header value equals expected
- assert_
no_ header - Assert response doesn’t have header
- assert_
status - Assert response status code
- create_
api_ test_ objects - Create test objects for API views
- create_
insecure_ request - Create a mock HTTP request (non-secure)
- create_
json_ request - Create a test request with JSON body
- create_
large_ test_ objects - Create a large set of test objects for pagination testing
- create_
request - Create a test HTTP request
- create_
request_ with_ headers - Create a test request with headers
- create_
request_ with_ path_ params - Create a test request with path parameters
- create_
response_ with_ headers - Create a response with custom headers
- create_
response_ with_ status - Create a response with custom status code
- create_
secure_ request - Create a mock HTTPS request
- create_
test_ objects - Create test objects for list views
- create_
test_ request - Create a mock HTTP request for testing with secure/insecure mode
- create_
test_ response - Create a mock response for testing
- create_
view_ request - Create a test request with the given parameters
- extract_
json - Extract and deserialize JSON from a response
- get_
header - Get header value from response
- has_
header - Check if response has a specific header
- header_
contains - Check if header contains substring
- header_
equals - Check if header has specific value
- init_
test_ logging - Initialize logging for tests (call once)
- poll_
until - Poll a condition until it becomes true or timeout is reached.
- random_
test_ key - Generate a random test key using UUID
- shutdown_
test_ server - Shuts down a test server gracefully
- spawn_
test_ server - Spawns a test server on a random available port
- test_
config_ value - Generate test configuration data with timestamp
- test_
server_ guard - Create a test server guard with the given router.
Type Aliases§
- Fixture
Result - Result type for fixture loading operations.