Skip to content

Proper Test Reorganization Plan

Problem with Previous Approach

Deleted whole files without analyzing content ❌ Lost unique edge case tests that target specific coverage lines
No clear structure for where to add new tests

Correct Approach

1. Analyze Content, Not Just File Names

  • Extract unique test functions from "duplicate" files
  • Identify specific edge cases that target uncovered lines
  • Preserve valuable coverage-boosting tests

2. Clear 2-3 Folder Structure

tests/
├── unit/                     # Core comprehensive tests (main functionality)
│   ├── test_core_comprehensive.py        # Main core functionality
│   ├── test_deserializers_comprehensive.py # Main deserialization
│   ├── test_api_comprehensive.py         # API functions
│   └── test_config_comprehensive.py      # Configuration
├── coverage/                 # Edge cases & coverage boosters
│   ├── test_core_edge_cases.py          # Import failures, object edge cases
│   ├── test_deserialization_edge_cases.py # Deserialization edge cases  
│   ├── test_error_paths.py              # Exception handling paths
│   └── test_performance_paths.py        # Hot paths & optimizations
└── integration/              # Integration & feature tests
    ├── test_ml_integration.py
    ├── test_pandas_integration.py
    └── test_round_trip.py

3. Function Migration Strategy

Core Module Functions to Extract & Organize:

FROM backup_removed_tests/test_core_coverage_boost.py → tests/coverage/test_core_edge_cases.py: - test_ml_serializers_import_failure - Tests import fallback (lines 14-15) - test_ml_serializer_function_fallback - Tests function fallback (lines 19-20)
- test_object_dict_method_exception - Tests dict() method exception (line 93) - test_object_without_dict_attribute - Tests no dict fallback (line 100) - test_object_vars_exception - Tests vars() exception (line 106)

FROM backup_removed_tests/test_core_error_paths.py → tests/coverage/test_error_paths.py: - Extract specific error condition tests - Exception handling edge cases - Security/limit boundary tests

Deserializer Functions:

FROM backup_removed_tests/test_deserializer_ultra_boost.py: - Extract unique optimization path tests - Template deserialization edge cases - Performance-critical path tests

4. Rules for Future Test Organization

tests/unit/ - Main Functionality

  • Add here: New core functionality tests
  • Add here: Basic happy path tests
  • Add here: Standard parameter variations

tests/coverage/ - Edge Cases & Coverage

  • Add here: Import failure scenarios
  • Add here: Exception handling edge cases
  • Add here: Object serialization edge cases
  • Add here: Boundary condition tests
  • Add here: Performance optimization paths

tests/integration/ - Integration Tests

  • Add here: Multi-module functionality
  • Add here: Real-world usage scenarios
  • Add here: Round-trip tests

Implementation Steps

  1. Create new organized structure files
  2. Extract unique functions from backed-up files
  3. Move functions (not files) to appropriate locations
  4. Verify coverage maintained
  5. Update documentation with clear guidelines

Success Criteria

  • ✅ Clear structure: Know exactly where to add new tests
  • ✅ Coverage maintained: All unique edge cases preserved
  • ✅ No duplication: Each test in exactly one logical place
  • ✅ Maintainable: Easy to find and modify relevant tests