* Initial plan * Migrate Category A test files to UnitTests.Parallelizable (135 tests) Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add 11 ButtonTests to Parallelizable, remove from UnitTests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add comprehensive test migration report Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add comprehensive performance analysis of UnitTests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Migrate 2 Autocomplete tests and add Text tests analysis Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add proof-of-concept: TextFormatter.Draw works in parallel tests with local driver Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add CreateFakeDriver helper to ParallelizableBase and migrate 4 TextFormatterTests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove proof-of-concept test from AutocompleteTests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Move Scheme-accessing tests back to UnitTests to fix intermittent failures Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update parallel tests README to document ConfigurationManager/SchemeManager restrictions Co-authored-by: tig <585482+tig@users.noreply.github.com> * Document static member restriction in parallel tests README Co-authored-by: tig <585482+tig@users.noreply.github.com> * Restore accidentally deleted ButtonTests.Accept_Cancel_Event_OnAccept_Returns_True test Co-authored-by: tig <585482+tig@users.noreply.github.com> * Migrate Accept_Cancel_Event_OnAccept_Returns_True test to Parallelizable Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com>
9.3 KiB
Text Tests Deep Dive and Migration Analysis
Overview
The Text/ folder in UnitTests contains 27 tests across 2 files that focus on text formatting and autocomplete functionality. This analysis examines each test to determine migration feasibility.
Test Files Summary
| File | Total Tests | AutoInitShutdown | SetupFakeDriver | No Attributes | Migratable |
|---|---|---|---|---|---|
| TextFormatterTests.cs | 23 | 0 | 18 | 5 | 15-18 (refactor) |
| AutocompleteTests.cs | 4 | 2 | 0 | 2 | 2 (migrated) |
| TOTAL | 27 | 2 | 18 | 7 | 17-20 (63-74%) |
AutocompleteTests.cs - Detailed Analysis
✅ MIGRATED (2 tests)
1. Test_GenerateSuggestions_Simple
Status: ✅ Migrated to UnitTests.Parallelizable
- Type: Pure unit test
- Tests: Suggestion generation logic
- Dependencies: None (no Application, no Driver)
- Why migratable: Tests internal logic only
2. TestSettingSchemeOnAutocomplete
Status: ✅ Migrated to UnitTests.Parallelizable
- Type: Pure unit test
- Tests: Scheme/color configuration
- Dependencies: None (no Application, no Driver)
- Why migratable: Tests property setting only
❌ REMAIN IN UNITTESTS (2 tests)
3. CursorLeft_CursorRight_Mouse_Button_Pressed_Does_Not_Show_Popup
Status: ❌ Must remain in UnitTests
- Type: Integration test
- Tests: Popup display behavior with keyboard/mouse interaction
- Dependencies:
[AutoInitShutdown], Application.Begin(), DriverAssert - Why not migratable:
- Tests full UI interaction workflow
- Verifies visual rendering of popup
- Requires Application.Begin() to set up event loop
- Uses DriverAssert to verify screen content
4. KeyBindings_Command
Status: ❌ Must remain in UnitTests
- Type: Integration test
- Tests: Keyboard navigation in autocomplete popup
- Dependencies:
[AutoInitShutdown], Application.Begin() - Why not migratable:
- Tests keyboard command handling in context
- Requires Application event loop
- Verifies state changes across multiple interactions
TextFormatterTests.cs - Detailed Analysis
Test Categorization
All 23 tests use [SetupFakeDriver] and test TextFormatter's Draw() method. However, many are testing formatting logic rather than actual rendering.
🟡 REFACTORABLE TESTS (15-18 tests can be converted)
These tests can be converted from testing Draw() output to testing Format() logic:
Horizontal Alignment Tests (10 tests) - HIGH PRIORITY
-
Draw_Horizontal_Centered (Theory with 9 InlineData)
- Tests horizontal centering logic
- Conversion: Use Format() instead of Draw(), verify string output
-
Draw_Horizontal_Justified (Theory with 9 InlineData)
- Tests text justification (Fill alignment)
- Conversion: Use Format() instead of Draw()
-
Draw_Horizontal_Left (Theory with 8 InlineData)
- Tests left alignment
- Conversion: Use Format() instead of Draw()
-
Draw_Horizontal_Right (Theory with 8 InlineData)
- Tests right alignment
- Conversion: Use Format() instead of Draw()
Direction Tests (2 tests)
-
Draw_Horizontal_RightLeft_TopBottom (Theory with 11 InlineData)
- Tests right-to-left text direction
- Conversion: Use Format() to test string manipulation logic
-
Draw_Horizontal_RightLeft_BottomTop (Theory with 9 InlineData)
- Tests right-to-left, bottom-to-top direction
- Conversion: Use Format() to test string manipulation
Size Calculation Tests (2 tests) - EASY WINS
-
FormatAndGetSize_Returns_Correct_Size
- Tests size calculation without actually rendering
- Conversion: Already doesn't need Draw(), just remove SetupFakeDriver
-
FormatAndGetSize_WordWrap_False_Returns_Correct_Size
- Tests size calculation with word wrap disabled
- Conversion: Already doesn't need Draw(), just remove SetupFakeDriver
Tab Handling Tests (3 tests) - EASY WINS
-
TabWith_PreserveTrailingSpaces_False
- Tests tab expansion logic
- Conversion: Use Format() to verify tab handling
-
TabWith_PreserveTrailingSpaces_True
- Tests tab expansion with preserved spaces
- Conversion: Use Format() to verify tab handling
-
TabWith_WordWrap_True
- Tests tab handling with word wrap
- Conversion: Use Format() to verify logic
❌ KEEP IN UNITTESTS (5-8 tests require actual rendering)
These tests verify actual console driver behavior and should remain:
Vertical Layout Tests (Variable - need individual assessment)
-
Draw_Vertical_BottomTop_LeftRight
- Complex vertical text layout
- May need driver to verify correct glyph positioning
-
Draw_Vertical_BottomTop_RightLeft
- Complex vertical text with RTL
- May need driver behavior
-
Draw_Vertical_Bottom_Horizontal_Right
- Mixed orientation layout
- Driver-dependent positioning
-
Draw_Vertical_TopBottom_LeftRight
-
Draw_Vertical_TopBottom_LeftRight_Middle
-
Draw_Vertical_TopBottom_LeftRight_Top
- Various vertical alignments
- Some may be convertible, others may need driver
Unicode/Rendering Tests (MUST STAY)
-
Draw_With_Combining_Runes
- Tests Unicode combining character rendering
- Must stay: Verifies actual glyph composition in driver
-
Draw_Vertical_Throws_IndexOutOfRangeException_With_Negative_Bounds
- Tests error handling with invalid bounds
- Must stay: Tests Draw() method directly
Complex Tests (NEED INDIVIDUAL REVIEW)
-
Draw_Text_Justification (Theory with 44 InlineData)
- Massive test with many scenarios
- Some may be convertible, others may need driver
-
Justify_Horizontal
- Tests justification logic
- Possibly convertible
-
UICatalog_AboutBox_Text
- Tests real-world complex text
- May need driver for full verification
Conversion Strategy
Step 1: Easy Conversions (5 tests - 30 minutes)
Convert tests that already mostly test logic:
- FormatAndGetSize_Returns_Correct_Size
- FormatAndGetSize_WordWrap_False_Returns_Correct_Size
- TabWith_PreserveTrailingSpaces_False
- TabWith_PreserveTrailingSpaces_True
- TabWith_WordWrap_True
Change required:
// Before
[SetupFakeDriver]
[Theory]
[InlineData(...)]
public void Test_Name(params)
{
tf.Draw(...);
DriverAssert.AssertDriverContentsWithFrameAre(expected, _output);
}
// After
[Theory]
[InlineData(...)]
public void Test_Name(params)
{
var result = tf.Format();
Assert.Equal(expected, result);
}
Step 2: Alignment Test Conversions (10 tests - 1-2 hours)
Convert horizontal alignment tests (Centered, Justified, Left, Right):
- Replace Draw() with Format()
- Remove DriverAssert, use Assert.Equal on string
- Test output logic without driver
Step 3: Direction Test Conversions (2 tests - 30 minutes)
Convert RightLeft direction tests:
- These manipulate strings, not render-specific
- Use Format() to verify string reversal logic
Step 4: Evaluate Vertical Tests (Variable - 1-2 hours)
Individually assess each vertical test:
- Some may be convertible to Format() logic tests
- Others genuinely test driver glyph positioning
- Keep those that need driver behavior
Step 5: Complex Test Assessment (3 tests - 1-2 hours)
Evaluate Draw_Text_Justification, Justify_Horizontal, UICatalog_AboutBox_Text:
- May require splitting into logic + rendering tests
- Logic parts can migrate, rendering parts stay
Expected Results
After Full Migration
- Migrated to Parallelizable: 17-20 tests (63-74%)
- Remaining in UnitTests: 7-10 tests (26-37%)
- 2 Autocomplete integration tests
- 5-8 TextFormatter rendering tests
Performance Impact
- Current Text/ tests: ~10.18s for 467 tests (from performance analysis)
- After migration: Estimated 8-9s for remaining integration tests
- Savings: ~1.2-2.2s (12-22% reduction in Text/ folder)
Test Quality Improvements
- Better test focus: Separates logic testing from rendering testing
- Faster feedback: Logic tests run in parallel without driver overhead
- Clearer intent: Tests named Format_* clearly test logic, Draw_* test rendering
- Easier maintenance: Logic tests don't depend on driver implementation details
Conclusion
The Text/ folder is an excellent candidate for migration because:
- 2 tests already migrated with zero refactoring (AutocompleteTests)
- 15-18 tests are testing logic but using driver unnecessarily
- Clear conversion pattern exists (Draw → Format)
- High success rate: 63-74% of tests can be migrated
The remaining 26-37% are legitimate integration tests that verify actual rendering behavior and should appropriately remain in UnitTests.
Next Steps
- ✅ DONE: Migrate 2 AutocompleteTests (Test_GenerateSuggestions_Simple, TestSettingSchemeOnAutocomplete)
- TODO: Convert 5 easy TextFormatterTests (FormatAndGetSize, TabWith tests)
- TODO: Convert 10 alignment tests (Horizontal Centered/Justified/Left/Right)
- TODO: Assess and convert 2-5 additional tests
- TODO: Document remaining tests as integration tests
Report Created: 2025-10-20 Tests Analyzed: 27 tests across 2 files Migration Status: 2/27 migrated (7.4%), 15-18/27 planned (63-74% total potential)