Overview
Refactor the UserOutput test suite to use parameterized tests with rstest, eliminating significant code duplication. Currently, many tests are nearly identical, differing only in the method called, expected symbol, verbosity level, and output channel. By using parameterized tests, we can express the same behavior matrix with much less code while maintaining clarity and improving maintainability.
Current State: The codebase already has simplified test infrastructure (Issue #123) with TestUserOutput helper, providing the foundation for this refactoring.
Specification
See detailed specification: docs/issues/128-parameterized-test-cases.md
(Link will be updated after issue number assignment and file rename)
🏗️ Architecture Requirements
DDD Layer: Presentation (Tests)
Module Path: src/presentation/user_output.rs (test module)
Pattern: Parameterized unit tests with rstest
Key Changes
- Add
rstest dependency to Cargo.toml dev-dependencies
- Create parameterized tests for channel routing (stdout vs stderr)
- Create parameterized tests for verbosity level behavior
- Create parameterized tests for message formatting
- Remove duplicate test methods
- Maintain or improve test coverage
Implementation Plan
Phase 1: Setup and Dependencies (30 minutes)
Phase 2: Identify Test Patterns (1 hour)
Phase 3: Create Parameterized Channel Routing Tests (2 hours)
Phase 4: Create Parameterized Verbosity Tests (2 hours)
Phase 5: Create Parameterized Formatting Tests (1 hour)
Phase 6: Remove Duplicate Tests (1 hour)
Phase 7: Validation and Documentation (1 hour)
Phase 8: Integration Testing (30 minutes)
Estimated Total Time: ~8.5 hours
Acceptance Criteria
Quality Checks:
Task-Specific Criteria:
Coverage Requirements:
Related
Benefits
✅ Reduced Duplication - one test implementation covers multiple cases
✅ Easier to Extend - adding new cases is as simple as adding a #[case(...)] line
✅ Clear Specification - test cases act as behavior documentation
✅ Maintainability - changes affect one test instead of many
✅ Better Coverage - easier to ensure all combinations are tested
✅ Consistent Testing - all cases use the same testing logic
Test Matrix
Message Type | Symbol | Verbosity | Channel | Always Shown
-------------|--------|-----------|---------|-------------
progress | ⏳ | Normal | stderr | No
success | ✅ | Normal | stderr | No
warning | ⚠️ | Normal | stderr | No
error | ❌ | Quiet | stderr | Yes
result | (none) | Quiet | stdout | Yes
steps | (none) | Normal | stderr | No
Overview
Refactor the
UserOutputtest suite to use parameterized tests withrstest, eliminating significant code duplication. Currently, many tests are nearly identical, differing only in the method called, expected symbol, verbosity level, and output channel. By using parameterized tests, we can express the same behavior matrix with much less code while maintaining clarity and improving maintainability.Current State: The codebase already has simplified test infrastructure (Issue #123) with
TestUserOutputhelper, providing the foundation for this refactoring.Specification
See detailed specification: docs/issues/128-parameterized-test-cases.md
(Link will be updated after issue number assignment and file rename)
🏗️ Architecture Requirements
DDD Layer: Presentation (Tests)
Module Path:
src/presentation/user_output.rs(test module)Pattern: Parameterized unit tests with rstest
Key Changes
rstestdependency toCargo.tomldev-dependenciesImplementation Plan
Phase 1: Setup and Dependencies (30 minutes)
rstest = "0.18"to dev-dependenciesPhase 2: Identify Test Patterns (1 hour)
Phase 3: Create Parameterized Channel Routing Tests (2 hours)
Phase 4: Create Parameterized Verbosity Tests (2 hours)
Phase 5: Create Parameterized Formatting Tests (1 hour)
Phase 6: Remove Duplicate Tests (1 hour)
Phase 7: Validation and Documentation (1 hour)
Phase 8: Integration Testing (30 minutes)
Estimated Total Time: ~8.5 hours
Acceptance Criteria
Quality Checks:
./scripts/pre-commit.shTask-Specific Criteria:
rstestdependency is added to dev-dependenciescargo llvm-cov)Coverage Requirements:
Related
Benefits
✅ Reduced Duplication - one test implementation covers multiple cases
✅ Easier to Extend - adding new cases is as simple as adding a
#[case(...)]line✅ Clear Specification - test cases act as behavior documentation
✅ Maintainability - changes affect one test instead of many
✅ Better Coverage - easier to ensure all combinations are tested
✅ Consistent Testing - all cases use the same testing logic
Test Matrix