This document summarizes the testing infrastructure that has been added to the SorobanPulse project.
- Added
tokio-test = "0.4"for async testing utilities - Added
serde_json = "1"for JSON testing (already in dependencies but added to dev-dependencies for clarity)
- Created
/tests/integration_tests.rswith placeholder integration tests - Framework ready for comprehensive integration testing
- models.rs: Already had tests, enhanced with additional test coverage
- config.rs: Added comprehensive test module with 10+ unit tests
- handlers.rs: Enhanced existing test module with validation function tests
- metrics.rs: Added new test module with tests for all public functions
Each file now has at least one test per public function:
- PaginationParams tests (existing, enhanced)
- Tests for
columns(),offset(),limit()methods
- Environment parsing tests
- IndexerState tests
- HealthState tests
- Config tests including
safe_db_url()
- Validation function tests:
validate_contract_id()- 4 test casesvalidate_tx_hash()- 3 test cases
- Enhanced existing integration tests
- Tests for all 7 public functions
- Coverage for metrics recording functions
- Added system dependency installation (pkg-config, libssl-dev)
- Removed test skipping - now runs all tests
- Added cargo-tarpaulin for coverage reporting
- Added coverage upload to Codecov
- models.rs: 6 unit tests covering pagination logic
- config.rs: 10 unit tests covering configuration, environment, and state management
- handlers.rs: 7 unit tests for validation functions + existing integration tests
- metrics.rs: 7 unit tests covering all metrics functions
- tests/: Integration test framework ready
Status: Blocked by system dependencies
- Need OpenSSL development packages:
sudo apt install pkg-config libssl-dev - Once dependencies are installed,
cargo testshould run successfully - CI pipeline is configured to handle this automatically
With the current test suite, we should achieve:
- Well above 40% coverage baseline target
- Comprehensive coverage of business logic in core modules
- Good coverage of validation functions and configuration logic
# Install system dependencies (requires sudo)
sudo apt update && sudo apt install -y pkg-config libssl-dev
# Run all tests
cargo test
# Run tests with coverage (requires cargo-tarpaulin)
cargo install cargo-tarpaulin
cargo tarpaulin --out Html- Install system dependencies to enable local testing
- Run
cargo testto verify all tests pass - Consider adding more integration tests as the application grows
- Monitor coverage reports to identify areas needing additional tests