TEST-INFRA: [test-architecture] Use Behave Background to reduce step duplication in Gherkin feature files #7452

Open
opened 2026-04-10 19:43:18 +00:00 by HAL9000 · 3 comments
Owner

Summary

The Behave feature file features/cli.feature contains duplicated steps across multiple scenarios. The step "When I run the CleverAgents CLI with..." is repeated in every scenario. This can be improved by using a Background section in the Gherkin feature file to define a common context for all scenarios in the file.

Proposal

Refactor the features/cli.feature file to use a Background section to reduce step duplication. This will make the feature file more concise and easier to maintain.

Example

A Background section would look like this:

Feature: CleverAgents CLI metadata

  Background:
    Given I am using the CleverAgents CLI

  Scenario: Display help
    When I run it with "--help"
    Then the output should contain "CleverAgents"

  Scenario: Display version
    When I run it with "--version"
    Then the output should contain "1.0.0"
...

This would require a new step definition for "Given I am using the CleverAgents CLI" and modifying the existing step definitions to accept "it" as a reference to the CLI.

Duplicate Check

  • Search queries: Behave Background Gherkin duplicate steps
  • Results: 1 match found, but it was not a duplicate. The matched issue was about a bug in the security scanner.
  • Conclusion: This is not a duplicate issue.

Metadata

  • Branch: test/test-architecture-behave-background-step-dedup
  • Commit Message: test(test-architecture): use Behave Background to reduce step duplication in cli.feature
  • Milestone: N/A (Backlog)
  • Parent Epic: #3204

Subtasks

  • Audit features/cli.feature for all duplicated steps across scenarios
  • Add a Background section to features/cli.feature with the common setup step
  • Add a new step definition Given I am using the CleverAgents CLI in features/steps/cli_steps.py
  • Refactor existing step definitions to accept "it" as a reference to the CLI where applicable
  • Verify all existing scenarios still pass after refactoring (nox -s unit_tests)
  • Ensure no AmbiguousStep errors are introduced

Definition of Done

  • features/cli.feature uses a Background section to eliminate duplicated setup steps
  • New step definition Given I am using the CleverAgents CLI is implemented in features/steps/cli_steps.py
  • All existing CLI feature scenarios pass without modification to their assertions
  • No AmbiguousStep errors in the Behave test suite
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.2.0. 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: new-issue-creator

## Summary The Behave feature file `features/cli.feature` contains duplicated steps across multiple scenarios. The step "When I run the CleverAgents CLI with..." is repeated in every scenario. This can be improved by using a `Background` section in the Gherkin feature file to define a common context for all scenarios in the file. ## Proposal Refactor the `features/cli.feature` file to use a `Background` section to reduce step duplication. This will make the feature file more concise and easier to maintain. ### Example A `Background` section would look like this: ```gherkin Feature: CleverAgents CLI metadata Background: Given I am using the CleverAgents CLI Scenario: Display help When I run it with "--help" Then the output should contain "CleverAgents" Scenario: Display version When I run it with "--version" Then the output should contain "1.0.0" ... ``` This would require a new step definition for "Given I am using the CleverAgents CLI" and modifying the existing step definitions to accept "it" as a reference to the CLI. ## Duplicate Check - **Search queries**: `Behave Background Gherkin duplicate steps` - **Results**: 1 match found, but it was not a duplicate. The matched issue was about a bug in the security scanner. - **Conclusion**: This is not a duplicate issue. ## Metadata - **Branch**: `test/test-architecture-behave-background-step-dedup` - **Commit Message**: `test(test-architecture): use Behave Background to reduce step duplication in cli.feature` - **Milestone**: N/A (Backlog) - **Parent Epic**: #3204 ## Subtasks - [ ] Audit `features/cli.feature` for all duplicated steps across scenarios - [ ] Add a `Background` section to `features/cli.feature` with the common setup step - [ ] Add a new step definition `Given I am using the CleverAgents CLI` in `features/steps/cli_steps.py` - [ ] Refactor existing step definitions to accept "it" as a reference to the CLI where applicable - [ ] Verify all existing scenarios still pass after refactoring (`nox -s unit_tests`) - [ ] Ensure no `AmbiguousStep` errors are introduced ## Definition of Done - [ ] `features/cli.feature` uses a `Background` section to eliminate duplicated setup steps - [ ] New step definition `Given I am using the CleverAgents CLI` is implemented in `features/steps/cli_steps.py` - [ ] All existing CLI feature scenarios pass without modification to their assertions - [ ] No `AmbiguousStep` errors in the Behave test suite - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. 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: new-issue-creator
Author
Owner

Verified — Test architecture improvement: Behave Background usage. MoSCoW: Could-have. Priority: Low.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Test architecture improvement: Behave Background usage. MoSCoW: Could-have. Priority: Low. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Author
Owner

Verified — Test architecture improvement: Behave Background usage. MoSCoW: Could-have. Priority: Low.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Test architecture improvement: Behave Background usage. MoSCoW: Could-have. Priority: Low. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Author
Owner

Verified — Test architecture improvement: Behave Background usage. MoSCoW: Could-have. Priority: Low.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Test architecture improvement: Behave Background usage. MoSCoW: Could-have. Priority: Low. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-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.

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