Testing Guide
This document provides information about testing OpenZeppelin Monitor, including running tests, generating coverage reports, and understanding the test structure.
Test Organization
The project includes comprehensive test suites organized into different categories:
Test Types
-
Unit Tests: Located within
src/
modules alongside the code they test -
Integration Tests: Located in
tests/integration/
directory -
Property-based Tests: Located in
tests/properties/
directory -
Mock Implementations: Located in
tests/integration/mocks/
Test Structure
tests/
├── integration/ # Integration tests
│ ├── blockchain/ # Blockchain client tests
│ ├── blockwatcher/ # Block monitoring tests
│ ├── filters/ # Filter logic tests
│ ├── fixtures/ # Test data and configurations
│ ├── mocks/ # Mock implementations
│ └── ...
├── properties/ # Property-based tests
│ ├── filters/ # Filter property tests
│ ├── notifications/ # Notification property tests
│ └── ...
└── integration.rs # Integration test entry point
Running Tests
Coverage Reports
Troubleshooting
Common Issues
Tests hanging or timing out:
- Ensure RUST_TEST_THREADS=1
is set
- Verify mock setups are correct
Coverage tool not found:
- Install with cargo install cargo-llvm-cov
- Add component with rustup component add llvm-tools-preview
Permission errors: - Ensure test directories are writable - Check file permissions on test fixtures
Contributing Tests
When contributing new features:
-
Add comprehensive tests for new functionality
-
Ensure all tests pass locally before submitting
-
Include both unit and integration tests where appropriate
-
Update test documentation if adding new test patterns
-
Maintain or improve code coverage
For more information about contributing, see the project’s contributing guidelines.