Files
cleveragents-core/features/plan_executor_coverage_boost.feature
T
freemo 051ee7c290 test(coverage): add Behave BDD tests to improve coverage across 52 source files
Added 52 new .feature files and corresponding _steps.py files targeting
previously uncovered code paths in the following areas:

- TUI layer: app, commands, persona (state/schema/registry), widgets,
  input (shell_exec, reference_parser)
- Application services: plan lifecycle/service/executor, session,
  project, repo indexing, correction, checkpoint, actor, llm_actors,
  strategy coordinator, resource file watcher, service retry wiring
- CLI commands: session, resource, repl, plan, db, automation_profile
- Domain models: retry_policy, resource_type, cost_budget,
  docker_compose_analyzer, detail_level, _sql_string_aware,
  _postgresql_helpers
- Core: circuit_breaker, retry_service_patterns
- Infrastructure: repositories, transaction_sandbox, strategy_registry,
  plugins/loader, container
- Config: settings
- Agents: plan_generation, context_analysis, auto_debug
- A2A: facade

All new tests follow the Behave/Gherkin BDD standard. Resolved step
definition collisions with unique prefixes. Fixed Alembic fileConfig
logger disabling issue (disable_existing_loggers=False).

ISSUES CLOSED: #1068
2026-03-20 21:22:10 +00:00

64 lines
2.9 KiB
Gherkin

Feature: PlanExecutor Coverage Boost
Additional scenarios that exercise previously uncovered code paths
in plan_executor.py, targeting lines 328-335, 384, 422, 458,
598-599, 612, and 619.
Background:
Given the plan executor module is imported
# --- _try_emit_metric success path (lines 328-330) ---
Scenario: _try_emit_metric emits a metric when emitter is configured
Given a PlanExecutor with a mock metrics emitter
When I trigger metric emission with a valid key and value
Then the metrics emitter should have received exactly one entry
# --- _try_emit_metric exception path (lines 331-335) ---
Scenario: _try_emit_metric silently handles emission failure
Given a PlanExecutor with a failing metrics emitter
When I trigger metric emission that causes an exception
Then no exception should propagate from metric emission
# --- _try_create_checkpoint returns None when sandbox is None (line 384) ---
Scenario: _try_create_checkpoint returns None when no sandbox is resolvable
Given a PlanExecutor with a checkpoint manager but no sandbox source
When I attempt to create a plan executor checkpoint
Then the checkpoint result should be None
# --- _try_rollback_to_last_checkpoint returns False when sandbox is None (line 422) ---
Scenario: _try_rollback_to_last_checkpoint returns False when no sandbox is resolvable
Given a PlanExecutor with a checkpoint manager but no sandbox source
When I attempt to rollback to the last checkpoint
Then the rollback result should be False
# --- _resolve_sandbox_for_checkpoint via execution_context (line 458) ---
Scenario: _resolve_sandbox_for_checkpoint returns sandbox from execution context
Given a PlanExecutor with an execution context that has a sandbox manager
When I resolve a sandbox for checkpointing
Then the resolved sandbox should come from the execution context
# --- _enforce_guardrails raises PlanError on step limit (lines 598-599) ---
Scenario: _enforce_guardrails raises PlanError when step limit is already reached
Given a PlanExecutor with a guardrail service that blocks step limit
When I enforce guardrails for a plan
Then a PlanError about step limit should be raised
# --- _enforce_guardrails_per_step returns when guardrails is None (line 612) ---
Scenario: _enforce_guardrails_per_step returns early when guardrails is None
Given a PlanExecutor with a guardrail service that returns no guardrails
When I enforce per-step guardrails
Then no exception should be raised from per-step enforcement
# --- _enforce_guardrails_per_step raises PlanError on wall-clock (line 619) ---
Scenario: _enforce_guardrails_per_step raises PlanError when wall-clock exceeded
Given a PlanExecutor with a guardrail service that blocks wall-clock per step
When I enforce per-step guardrails expecting wall-clock error
Then a PlanError about wall-clock limit should be raised from per-step