perf(tests): optimize the 8 slowest BDD feature files #488

Closed
brent.edwards wants to merge 1 commits from perf/optimize-slowest-features into perf/shared-fixtures-lazy-imports

1 Commits

Author SHA1 Message Date
brent.edwards 8dda3df3e0 perf(tests): optimize the 8 slowest BDD feature files
Reduce behave-internal execution time for the 8 slowest features
(originally 113-248s each, now 0.7-31.6s behave-internal time):

features/environment.py:
- Add _ensure_template_db() for direct behave invocations (outside nox)
  so the template DB fast-path is always active.
- Expand _SCENARIO_DB_PREFIXES to include "test_" so step-file-created
  databases (services_coverage, etc.) also get the template copy.
- Add @mock_only tag support in before_scenario to skip unnecessary
  temp DB file creation for fully-mocked features.

features/plan_commands_coverage.feature:
- Add @mock_only tag — this feature uses fully mocked services and
  never touches the database, so DB setup is pure waste.

features/plan_service.feature:
- Change 14 actor-resolution scenarios from "Given I have a plan
  service" (heavyweight: file-based DB + project init) to "Given I have
  a lightweight plan service for actor testing" (in-memory DB, no
  project init).

features/steps/plan_service_steps.py:
- Add step_create_lightweight_plan_service for actor-resolution tests
  that only need PlanService with in-memory UoW.

features/steps/services_coverage_steps.py:
- Extract _setup_context_service(), _setup_plan_service(), and
  _setup_project_service() helpers to consolidate 8 near-identical
  Given steps that each had ~30 lines of duplicated DB setup
  boilerplate. Reduces code by ~200 lines with no behavior change.

Part of #478. Closes #479.
2026-03-01 05:33:58 +00:00