TEST-INFRA: [test-data-quality] 200+ inline mock/fake/stub class definitions in step files violate features/mocks/ placement rule #10089

Open
opened 2026-04-16 22:41:36 +00:00 by HAL9000 · 0 comments
Owner

Metadata

Field Value
Branch test/test-data-quality-consolidate-inline-mocks
Commit Message test(infra): consolidate inline mock/fake/stub classes from step files into features/mocks/
Milestone v3.6.0
Parent Epic

Background and Context

CONTRIBUTING.md mandates: "Mocks must be in features/mocks/ ONLY". However, 80 step files in features/steps/ define 200+ inline mock, fake, and stub class definitions directly within step files. This violates the placement rule and creates several problems:

  1. CONTRIBUTING.md violation: Mock implementations scattered across step files instead of centralized in features/mocks/.
  2. Code duplication: Similar mock patterns (e.g., _StubRepository, _StubUnitOfWork, _StubTransaction) are redefined independently in multiple step files with slight variations, making maintenance harder.
  3. Discoverability: Developers looking for mock implementations must search across 80+ step files instead of finding them in the canonical features/mocks/ directory.
  4. Reusability: Inline mocks cannot be shared across step files without importing from step files (which is an anti-pattern).

Evidence: Running grep -rln "class.*Mock\|class.*Fake\|class.*Stub" features/steps/ reveals 80 files with inline class definitions. Examples:

  • features/steps/actor_service_steps.py: defines _StubActorRepository, _StubTransaction, _StubUnitOfWork
  • features/steps/plan_service_steps.py: defines _StubProvider, _StubRegistry, _StreamingStubProvider, _ActorServiceStub (×4 variants), FakePlansRepository, FakeContextsRepository, FakeDebugAttemptsRepository, FakeUnitOfWork, _StubPlansRepository, _StubTransaction
  • features/steps/a2a_facade_coverage_boost_steps.py: defines _MockPlanIdentity, _MockPlan
  • 77 additional step files with similar inline definitions

The features/mocks/ directory already contains proper mock implementations (mock_ai_provider.py, mock_devcontainer_cli.py, mock_mcp_transport.py, mock_strategy_llm.py, etc.) demonstrating the correct pattern.


Expected Behavior

All mock, fake, and stub class definitions are located exclusively in features/mocks/ modules. Step files in features/steps/ import from features/mocks/ rather than defining their own inline mock classes. Shared mock patterns (e.g., _StubUnitOfWork) exist as single canonical implementations reused across multiple step files.


Acceptance Criteria

  • No class.*Mock, class.*Fake, or class.*Stub definitions remain in any features/steps/ file
  • All mock/fake/stub implementations are consolidated into features/mocks/ modules
  • Shared mock patterns (e.g., _StubUnitOfWork) are consolidated into single reusable implementations
  • All step files that previously defined inline mocks now import from features/mocks/
  • All nox stages pass without regressions
  • Coverage >= 97%

Subtasks

  • Audit all 80 step files with inline mock/fake/stub class definitions and catalog them
  • Identify which inline mocks are duplicated across multiple step files (e.g., _StubUnitOfWork pattern)
  • For duplicated mocks: create shared implementations in features/mocks/ and update all step files to import from there
  • For unique mocks: move each to an appropriately named module in features/mocks/ (e.g., features/mocks/plan_service_stubs.py)
  • Update all step file imports to reference the new features/mocks/ locations
  • Run nox -s unit_tests to confirm no regressions
  • Run nox -s coverage_report to confirm coverage >= 97%

Definition of Done

This issue should be closed when:

  • No class.*Mock, class.*Fake, or class.*Stub definitions remain in features/steps/ files
  • All mock/fake/stub implementations are in features/mocks/ modules
  • Shared mock patterns (e.g., _StubUnitOfWork) are consolidated into single reusable implementations
  • All nox stages pass
  • Coverage >= 97%

Duplicate Check

Searched open and closed issues for: "mock steps", "inline mock", "features/mocks", "mock class step", "mock class step file", "mocks features"

  • No existing open or closed issues found that track the problem of inline mock/fake/stub class definitions in step files violating the features/mocks/ placement rule.
  • Issue #8420 ("cli_plan_context_commands_steps.py defines after_scenario hook outside environment.py") is about misplaced lifecycle hooks, not mock class placement. Different issue.
  • Issue #729 ("remove dead after_scenario hooks from step files") is about dead hooks, not mock placement. Different issue.

No existing issue tracks the specific violation of 200+ inline mock class definitions in step files that should be in features/mocks/.


Automated by CleverAgents Bot
Supervisor: Test Infrastructure Pool | Agent: test-infra-pool-supervisor

## Metadata | Field | Value | |---|---| | **Branch** | `test/test-data-quality-consolidate-inline-mocks` | | **Commit Message** | `test(infra): consolidate inline mock/fake/stub classes from step files into features/mocks/` | | **Milestone** | v3.6.0 | | **Parent Epic** | — | --- ## Background and Context CONTRIBUTING.md mandates: **"Mocks must be in `features/mocks/` ONLY"**. However, 80 step files in `features/steps/` define 200+ inline mock, fake, and stub class definitions directly within step files. This violates the placement rule and creates several problems: 1. **CONTRIBUTING.md violation**: Mock implementations scattered across step files instead of centralized in `features/mocks/`. 2. **Code duplication**: Similar mock patterns (e.g., `_StubRepository`, `_StubUnitOfWork`, `_StubTransaction`) are redefined independently in multiple step files with slight variations, making maintenance harder. 3. **Discoverability**: Developers looking for mock implementations must search across 80+ step files instead of finding them in the canonical `features/mocks/` directory. 4. **Reusability**: Inline mocks cannot be shared across step files without importing from step files (which is an anti-pattern). **Evidence**: Running `grep -rln "class.*Mock\|class.*Fake\|class.*Stub" features/steps/` reveals 80 files with inline class definitions. Examples: - `features/steps/actor_service_steps.py`: defines `_StubActorRepository`, `_StubTransaction`, `_StubUnitOfWork` - `features/steps/plan_service_steps.py`: defines `_StubProvider`, `_StubRegistry`, `_StreamingStubProvider`, `_ActorServiceStub` (×4 variants), `FakePlansRepository`, `FakeContextsRepository`, `FakeDebugAttemptsRepository`, `FakeUnitOfWork`, `_StubPlansRepository`, `_StubTransaction` - `features/steps/a2a_facade_coverage_boost_steps.py`: defines `_MockPlanIdentity`, `_MockPlan` - 77 additional step files with similar inline definitions The `features/mocks/` directory already contains proper mock implementations (`mock_ai_provider.py`, `mock_devcontainer_cli.py`, `mock_mcp_transport.py`, `mock_strategy_llm.py`, etc.) demonstrating the correct pattern. --- ## Expected Behavior All mock, fake, and stub class definitions are located exclusively in `features/mocks/` modules. Step files in `features/steps/` import from `features/mocks/` rather than defining their own inline mock classes. Shared mock patterns (e.g., `_StubUnitOfWork`) exist as single canonical implementations reused across multiple step files. --- ## Acceptance Criteria - No `class.*Mock`, `class.*Fake`, or `class.*Stub` definitions remain in any `features/steps/` file - All mock/fake/stub implementations are consolidated into `features/mocks/` modules - Shared mock patterns (e.g., `_StubUnitOfWork`) are consolidated into single reusable implementations - All step files that previously defined inline mocks now import from `features/mocks/` - All nox stages pass without regressions - Coverage >= 97% --- ## Subtasks - [ ] Audit all 80 step files with inline mock/fake/stub class definitions and catalog them - [ ] Identify which inline mocks are duplicated across multiple step files (e.g., `_StubUnitOfWork` pattern) - [ ] For duplicated mocks: create shared implementations in `features/mocks/` and update all step files to import from there - [ ] For unique mocks: move each to an appropriately named module in `features/mocks/` (e.g., `features/mocks/plan_service_stubs.py`) - [ ] Update all step file imports to reference the new `features/mocks/` locations - [ ] Run `nox -s unit_tests` to confirm no regressions - [ ] Run `nox -s coverage_report` to confirm coverage >= 97% --- ## Definition of Done This issue should be closed when: - [ ] No `class.*Mock`, `class.*Fake`, or `class.*Stub` definitions remain in `features/steps/` files - [ ] All mock/fake/stub implementations are in `features/mocks/` modules - [ ] Shared mock patterns (e.g., `_StubUnitOfWork`) are consolidated into single reusable implementations - [ ] All nox stages pass - [ ] Coverage >= 97% --- ## Duplicate Check Searched open and closed issues for: "mock steps", "inline mock", "features/mocks", "mock class step", "mock class step file", "mocks features" - No existing open or closed issues found that track the problem of inline mock/fake/stub class definitions in step files violating the `features/mocks/` placement rule. - Issue #8420 ("cli_plan_context_commands_steps.py defines after_scenario hook outside environment.py") is about misplaced lifecycle hooks, not mock class placement. Different issue. - Issue #729 ("remove dead after_scenario hooks from step files") is about dead hooks, not mock placement. Different issue. No existing issue tracks the specific violation of 200+ inline mock class definitions in step files that should be in `features/mocks/`. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure Pool | Agent: test-infra-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#10089
No description provided.