TEST-INFRA: [test-architecture] Refactor Behave step definitions for better organization and reusability #3625

Open
opened 2026-04-05 20:54:06 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: refactor/test-arch-behave-step-definitions
  • Commit Message: refactor(tests): reorganize Behave step definitions into shared and feature-specific modules
  • Milestone: (none — backlog)
  • Parent Epic: #3398

Background and context

The current organization of Behave step definitions in features/steps/ can be improved to enhance reusability and maintainability. Currently, there is a mix of generic and feature-specific steps within the same files, and there is no dedicated location for shared steps. This makes it difficult to find and reuse existing steps, leading to potential code duplication and increased maintenance overhead.

Current behavior

  • Generic steps in feature-specific files: Files like features/steps/cli_steps.py contain highly reusable steps (e.g., for checking CLI output and exit codes) that are applicable to many features, not just cli.feature.
  • Lack of a dedicated shared steps module: There is no clear convention or location for storing shared step definitions. Shared steps are scattered across different files, such as features/steps/cli_coverage_steps.py.
  • Unclear Naming: Some step definition files have names that do not accurately reflect their content. For example, features/steps/cli_coverage_steps.py contains general-purpose CLI steps, not just steps related to coverage.

Expected behavior

  • All shared step definitions should be located in a dedicated directory, such as features/steps/shared/.
  • Feature-specific step definition files should only contain steps that are unique to that feature.
  • Step definition files should be named clearly and accurately to reflect their purpose and scope.

Subtasks

  • Create a new directory features/steps/shared/ for shared step definitions.
  • Create a new file features/steps/shared/cli_steps.py and move all generic CLI-related steps from features/steps/cli_steps.py and features/steps/cli_coverage_steps.py to this new file.
  • Refactor features/steps/cli_steps.py to only contain steps that are specific to cli.feature.
  • Rename features/steps/cli_coverage_steps.py to a more descriptive name, such as cli_coverage_scenarios_steps.py, and ensure it only contains steps specific to the coverage scenarios.
  • Review other step definition files and identify other opportunities for refactoring and reorganization.
  • Verify all Behave scenarios still pass after reorganization (nox -e unit_tests)
  • Verify coverage remains >= 97% (nox -e coverage_report)
  • Run all nox stages and confirm they pass

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone active. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `refactor/test-arch-behave-step-definitions` - **Commit Message**: `refactor(tests): reorganize Behave step definitions into shared and feature-specific modules` - **Milestone**: *(none — backlog)* - **Parent Epic**: #3398 ## Background and context The current organization of Behave step definitions in `features/steps/` can be improved to enhance reusability and maintainability. Currently, there is a mix of generic and feature-specific steps within the same files, and there is no dedicated location for shared steps. This makes it difficult to find and reuse existing steps, leading to potential code duplication and increased maintenance overhead. ## Current behavior - **Generic steps in feature-specific files:** Files like `features/steps/cli_steps.py` contain highly reusable steps (e.g., for checking CLI output and exit codes) that are applicable to many features, not just `cli.feature`. - **Lack of a dedicated shared steps module:** There is no clear convention or location for storing shared step definitions. Shared steps are scattered across different files, such as `features/steps/cli_coverage_steps.py`. - **Unclear Naming:** Some step definition files have names that do not accurately reflect their content. For example, `features/steps/cli_coverage_steps.py` contains general-purpose CLI steps, not just steps related to coverage. ## Expected behavior - All shared step definitions should be located in a dedicated directory, such as `features/steps/shared/`. - Feature-specific step definition files should only contain steps that are unique to that feature. - Step definition files should be named clearly and accurately to reflect their purpose and scope. ## Subtasks - [ ] Create a new directory `features/steps/shared/` for shared step definitions. - [ ] Create a new file `features/steps/shared/cli_steps.py` and move all generic CLI-related steps from `features/steps/cli_steps.py` and `features/steps/cli_coverage_steps.py` to this new file. - [ ] Refactor `features/steps/cli_steps.py` to only contain steps that are specific to `cli.feature`. - [ ] Rename `features/steps/cli_coverage_steps.py` to a more descriptive name, such as `cli_coverage_scenarios_steps.py`, and ensure it only contains steps specific to the coverage scenarios. - [ ] Review other step definition files and identify other opportunities for refactoring and reorganization. - [ ] Verify all Behave scenarios still pass after reorganization (`nox -e unit_tests`) - [ ] Verify coverage remains >= 97% (`nox -e coverage_report`) - [ ] Run all nox stages and confirm they pass ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass - Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone *active*. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-05 20:54:48 +00:00
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.

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