# Story 7.5: Consolidate Duplicative Logger Test Files

**Status:** Complete
**Priority:** P1
**Depends on:** 7.1 (Refactor Coverage-Padding Tests)
**Effort:** L (2-3 days)
**Completed:** 2026-01-09

---

## Problem Statement

The test suite has 23+ logger-related test files in `tests/unit/`, many with overlapping coverage:

- `test_core_logger.py`
- `test_core_logger_fastpath.py`
- `test_core_logger_fastpath_fallback.py`
- `test_core_logger_self_test.py`
- `test_core_logger_no_copy_enqueue.py`
- `test_async_logger_facade.py`
- `test_async_logger_factory.py`
- `test_logger_correlation.py`
- `test_logger_diagnostics.py`
- `test_logger_error_containment.py`
- `test_logger_features.py`
- `test_logger_flush_paths.py`
- `test_logger_initialization.py`
- `test_logger_metrics_integration.py`
- `test_logger_mixin_shared.py`
- `test_logger_sampling_pipeline.py`
- `test_logger_setup_shared.py`
- `test_logger_thread_lifecycle.py`
- `test_logger_thread_mode.py`
- `test_logger_worker.py`
- `test_logger_workers.py`
- `test_get_logger_fastpath_wiring.py`
- `test_get_logger_file_sink.py`

This proliferation creates:
- **Maintenance burden**: Similar tests scattered across many files
- **Discovery difficulty**: Hard to find where a behavior is tested
- **Overlap and redundancy**: Same behaviors tested in multiple places
- **Naming confusion**: `test_logger_worker.py` vs `test_logger_workers.py`

---

## Goals

1. **Reduce file count** by consolidating related tests
2. **Improve discoverability** with logical groupings
3. **Remove redundant tests** that test the same behavior
4. **Establish clear naming conventions** for test organization

---

## Acceptance Criteria

- [x] Logger test files consolidated from 23+ to ~8-10 well-organized files (23 → 10)
- [x] No loss of behavioral coverage (only removal of redundant tests)
- [x] Each consolidated file has a clear scope documented in its docstring
- [x] Test discovery time remains acceptable (<5s for full suite)
- [x] Coverage remains at 90%+ (90.48%)

---

## Technical Approach

### Proposed Consolidation

| New File | Consolidates | Scope |
|----------|--------------|-------|
| `test_logger_core.py` | `test_core_logger.py`, `test_core_logger_self_test.py` | Core logger behavior |
| `test_logger_async.py` | `test_async_logger_facade.py`, `test_async_logger_factory.py` | Async-specific behavior |
| `test_logger_fastpath.py` | `test_core_logger_fastpath.py`, `test_core_logger_fastpath_fallback.py`, `test_get_logger_fastpath_wiring.py` | Fast path optimization |
| `test_logger_threading.py` | `test_logger_thread_mode.py`, `test_logger_thread_lifecycle.py`, `test_logger_worker.py`, `test_logger_workers.py` | Threading and workers |
| `test_logger_pipeline.py` | `test_logger_sampling_pipeline.py`, `test_logger_flush_paths.py` | Pipeline stages |
| `test_logger_context.py` | `test_logger_correlation.py`, `test_logger_diagnostics.py` | Context and correlation |
| `test_logger_errors.py` | `test_logger_error_containment.py` | Error handling |
| `test_logger_sinks.py` | `test_get_logger_file_sink.py` | Sink integration |
| `test_logger_setup.py` | `test_logger_initialization.py`, `test_logger_setup_shared.py`, `test_logger_mixin_shared.py` | Setup and initialization |
| `test_logger_features.py` | `test_logger_features.py`, `test_logger_metrics_integration.py`, `test_core_logger_no_copy_enqueue.py` | Feature tests |

### Process

1. **Audit each file**: Document what behaviors each test covers
2. **Identify duplicates**: Flag tests that verify the same behavior
3. **Merge carefully**: Move tests to consolidated files, preserving test names
4. **Remove redundant tests**: Delete tests that duplicate coverage
5. **Update imports**: Ensure any shared fixtures are properly referenced
6. **Verify coverage**: Run coverage report before and after

### File Organization Within Each Consolidated File

```python
"""
Test logger core behavior.

Scope:
- Logger instantiation
- Log level handling
- Event creation
- Basic emit flow

Does NOT cover:
- Threading (see test_logger_threading.py)
- Async-specific behavior (see test_logger_async.py)
- Fast path optimization (see test_logger_fastpath.py)
"""


class TestLoggerInstantiation:
    """Tests for logger creation and configuration."""
    ...


class TestLogLevels:
    """Tests for log level filtering and handling."""
    ...


class TestEventCreation:
    """Tests for log event construction."""
    ...
```

---

## Risk Assessment

**Risk Level: Low**

- Tests only, no production code changes
- Git history preserved with careful commits
- Can be done incrementally (one consolidation at a time)
- Easy to revert individual merges if issues found

---

## Rollback Plan

Each consolidation should be a separate commit. If issues are found:
1. Identify which consolidation caused the issue
2. Revert that specific commit
3. Investigate before re-attempting

---

## Definition of Done

- [x] Logger test files reduced to ~8-10 files (now 10 files)
- [x] Each file has clear scope documentation
- [x] No duplicate tests remain
- [x] All tests pass (160 logger tests, 1398 total)
- [x] Coverage >= 90% (90.48%)
- [ ] CI passes
- [ ] Consolidation documented in PR description

---

## Related Stories

- **7.1**: Refactor Coverage-Padding Tests (should complete first)
- **7.4**: Test Assertion Strength Lint (should pass after consolidation)

---

## Future Considerations

- Apply same consolidation approach to plugin test files
- Consider test file naming conventions for entire test suite
- Evaluate pytest markers for logical grouping within files
