Add targeted coverage tests to maintain >80% code coverage minimum: - ExtractInput error paths (14 tests): Type mismatch errors for Result, Option, Vec, HashMap, Arc, and primitive types. Directly exercises error formatting code that was previously uncovered. - DagRunner::get() type mismatch (6 tests): Covers the type mismatch error path when attempting to retrieve task output with wrong type. Tests various type combinations to ensure robust error handling. - TaskBuilder conversions (9 tests): Covers the From<TaskBuilder> to TaskHandle conversion for unit-type tasks, ensuring ID preservation and correct handling of mixed task types. Also fixes timing test threshold from 10ms to 50ms to account for tarpaulin instrumentation overhead while still validating parallel execution. Coverage increased from ~78% to 82.04% (above 80% minimum requirement).
Test Suite
Purpose
Integration and performance tests for dagx. Unit tests live in src/{module}/tests.rs.
Directory Structure
tests/
├── common/ # Shared test utilities
├── dependencies/ # Dependency resolution tests
├── execution/ # Task execution and DAG running
├── parallelism/ # Parallel execution verification
├── panic/ # Panic handling and isolation
├── performance/ # Stress tests and benchmarks
├── runtimes/ # Runtime compatibility tests
├── task_patterns/ # Common task pattern tests
├── type_safety/ # Type system validation
└── lib_tests.rs # Main test entry point
Running Tests
# All tests (unit + integration)
cargo test
# Unit tests only
cargo test --lib
# Integration tests only
cargo test --test lib_tests
# Specific category
cargo test --test lib_tests -- parallelism::
cargo test --test lib_tests -- execution::
# With output
cargo test -- --nocapture
# Single threaded (for debugging)
cargo test -- --test-threads=1
# Performance tests (excluded by default)
cargo test --release -- --ignored
Test Categories
Unit Tests (src/{module}/tests.rs)
- Module-specific logic
- Edge cases and error conditions
- Type implementations
Integration Tests (tests/)
- execution: End-to-end DAG execution
- dependencies: Complex dependency graphs
- parallelism: Concurrent task execution
- panic: Error propagation and isolation
- performance: Large DAGs and stress tests
- runtimes: Tokio, async-std, smol compatibility
- task_patterns: Common usage patterns
- type_safety: Type system guarantees
Writing Tests
Integration tests use common utilities from tests/common/mod.rs.
Unit tests should:
- Test single units of functionality
- Mock external dependencies
- Cover error cases
Integration tests should:
- Test component interactions
- Use real implementations
- Verify end-to-end behavior