Repository navigation
Closed
Description
Overview
Simplify the test infrastructure for UserOutput by replacing complex Arc<Mutex<Vec<u8>>> and custom SharedWriter with a simpler, more maintainable TestUserOutput wrapper. This makes test code easier to understand and reduces cognitive load for contributors.
Specification
See detailed specification: docs/issues/123-simplify-test-infrastructure.md
🏗️ Architecture Requirements
DDD Layer: Presentation (Test Support Module)
Module Path: src/presentation/user_output.rs (test module)
Pattern: Test Helper Struct
Module Structure Requirements
- Keep test infrastructure in
#[cfg(test)]module withinuser_output.rs - Create
TestUserOutputhelper struct for test scenarios - Maintain separation between production code and test helpers
- Follow module organization conventions (see docs/contributing/module-organization.md)
Architectural Constraints
- Test-only code: All changes confined to
#[cfg(test)]modules - No breaking changes: Production
UserOutputAPI unchanged - Standard library preference: Use
Vec<u8>and standard types over complex wrappers - Simplicity over cleverness: Favor readable code over minimal boilerplate
Anti-Patterns to Avoid
- ❌ Over-engineering test infrastructure - Don't add unnecessary abstractions
- ❌ Leaking test code to production - Keep test helpers in test modules only
- ❌ Complex synchronization primitives - Avoid
Arc<Mutex<>>unless truly needed
Implementation Plan
Phase 1: Create New Test Infrastructure (1-2 hours)
- Create
test_supportmodule in#[cfg(test)]section - Implement
TestUserOutputstruct with accessor methods - Implement
TestWriterwithWritetrait - Add documentation for test infrastructure
Phase 2: Update Existing Tests (2-3 hours)
- Identify all tests using
create_test_user_output() - Update tests to use
TestUserOutput::new() - Simplify test code with new cleaner API
- Verify all tests pass
Phase 3: Remove Old Infrastructure (30 minutes)
- Remove
SharedWriterstruct - Remove
create_test_user_output()function - Run linter and fix warnings
Phase 4: Documentation and Verification (30 minutes)
- Add module documentation
- Run full test suite
- Run pre-commit checks:
./scripts/pre-commit.sh
Acceptance Criteria
Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
Quality Checks:
- Pre-commit checks pass:
./scripts/pre-commit.sh
Infrastructure Checks:
-
TestUserOutputstruct exists in test module - All accessor methods implemented:
stdout(),stderr(),output(),clear() - Old
SharedWriterandcreate_test_user_output()removed
Test Migration Checks:
- All tests updated to new infrastructure
- No remaining references to old helpers
- All tests pass
- Test code is simpler and more readable
Code Quality Checks:
- Test infrastructure well-documented
- Usage examples provided
- Standard library types used (
Rc<RefCell<>>instead ofArc<Mutex<>>)
Related
- Parent: [EPIC] User Output Architecture Improvements #102 (Epic: User Output Architecture Improvements)
- Roadmap: N/A (Code quality improvement)
- Specification: docs/issues/123-simplify-test-infrastructure.md
Reacted by Copilot
Activity
docs: add Phase 0 issue specifications for user output refactoring
Merge #131: Refactor UserOutput tests to use rstest parameterized tes…
chore: remove closed issue documentation files