TEST-INFRA: [test-architecture] AmbiguousStep error in Behave step definitions #1864

Open
opened 2026-04-03 00:01:24 +00:00 by freemo · 3 comments
Owner

Metadata

  • Branch: fix/test-arch-ambiguous-step-tui-rendered-text
  • Commit Message: fix(tests): remove AmbiguousStep collision for rendered-text step in Behave step definitions
  • Milestone: v3.2.0
  • Parent Epic: #739

Background and Context

The unit_tests nox session is failing with a behave.step_registry.AmbiguousStep error. This indicates that the same step definition pattern is registered in two different step files, which causes Behave to crash immediately — preventing all unit tests from running.

Per CONTRIBUTING.md, the BDD test organisation guidelines require that step definitions are not duplicated across files. Steps used across multiple features must be consolidated into a shared, purpose-driven module.

Current Behavior

Running nox -s unit_tests crashes with the following error:

behave.step_registry.AmbiguousStep: @then('the rendered text should contain "{text}"') has already been defined in
  existing step @then('the rendered text should contain "{text}"') at features/steps/tui_first_run_steps.py:236

The same @then('the rendered text should contain "{text}"') step pattern is defined in both:

  • features/steps/tui_thought_block_steps.py
  • features/steps/tui_first_run_steps.py

This causes nox -s unit_tests to crash immediately — zero tests run.

Expected Behavior

Each step pattern must be registered exactly once. The step definitions must be refactored so that each file uses a unique, domain-prefixed step pattern, or the shared step is moved to a common shared steps module. nox -s unit_tests must run to completion with no AmbiguousStep errors.

Acceptance Criteria

  • The @then('the rendered text should contain "{text}"') step pattern is no longer duplicated across step files
  • All .feature files that reference the old step pattern are updated to use the new domain-specific or shared pattern
  • nox -s unit_tests runs to completion with no AmbiguousStep crash
  • nox -s coverage_report passes with coverage ≥ 97%

Supporting Information

  • To reproduce: run nox -s unit_tests
  • Related broader issue: #1806 (553 ambiguous step patterns across the codebase)
  • Related issue: #1847 (same root cause, same step pattern)
  • CONTRIBUTING.md BDD Test Organisation Guidelines: "Group new steps with related ones" and "Keep shared steps in purpose-driven modules"

Subtasks

  • Identify the duplicate @then('the rendered text should contain "{text}"') step in both tui_thought_block_steps.py and tui_first_run_steps.py
  • Decide on resolution strategy: domain-prefix rename or consolidation into a shared steps module
  • Apply the chosen fix (rename or consolidate) to eliminate the duplicate registration
  • Update all .feature files referencing the old step pattern to use the new pattern
  • Run behave --dry-run to confirm zero AmbiguousStep errors for this pattern
  • Run nox -s unit_tests to confirm the quality gate passes
  • Run full nox suite and confirm all sessions pass
  • Verify coverage >= 97% via nox -s coverage_report

Definition of Done

  • The duplicate @then('the rendered text should contain "{text}"') step pattern is eliminated
  • All affected .feature files updated to use the renamed or consolidated step pattern
  • nox -s unit_tests runs to completion with no AmbiguousStep crash
  • All nox stages pass
  • Coverage >= 97%
  • 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

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

## Metadata - **Branch**: `fix/test-arch-ambiguous-step-tui-rendered-text` - **Commit Message**: `fix(tests): remove AmbiguousStep collision for rendered-text step in Behave step definitions` - **Milestone**: v3.2.0 - **Parent Epic**: #739 ## Background and Context The `unit_tests` nox session is failing with a `behave.step_registry.AmbiguousStep` error. This indicates that the same step definition pattern is registered in two different step files, which causes Behave to crash immediately — preventing all unit tests from running. Per `CONTRIBUTING.md`, the BDD test organisation guidelines require that step definitions are not duplicated across files. Steps used across multiple features must be consolidated into a shared, purpose-driven module. ## Current Behavior Running `nox -s unit_tests` crashes with the following error: ``` behave.step_registry.AmbiguousStep: @then('the rendered text should contain "{text}"') has already been defined in existing step @then('the rendered text should contain "{text}"') at features/steps/tui_first_run_steps.py:236 ``` The same `@then('the rendered text should contain "{text}"')` step pattern is defined in both: - `features/steps/tui_thought_block_steps.py` - `features/steps/tui_first_run_steps.py` This causes `nox -s unit_tests` to crash immediately — zero tests run. ## Expected Behavior Each step pattern must be registered exactly once. The step definitions must be refactored so that each file uses a unique, domain-prefixed step pattern, or the shared step is moved to a common shared steps module. `nox -s unit_tests` must run to completion with no `AmbiguousStep` errors. ## Acceptance Criteria - [ ] The `@then('the rendered text should contain "{text}"')` step pattern is no longer duplicated across step files - [ ] All `.feature` files that reference the old step pattern are updated to use the new domain-specific or shared pattern - [ ] `nox -s unit_tests` runs to completion with no `AmbiguousStep` crash - [ ] `nox -s coverage_report` passes with coverage ≥ 97% ## Supporting Information - To reproduce: run `nox -s unit_tests` - Related broader issue: #1806 (553 ambiguous step patterns across the codebase) - Related issue: #1847 (same root cause, same step pattern) - `CONTRIBUTING.md` BDD Test Organisation Guidelines: "Group new steps with related ones" and "Keep shared steps in purpose-driven modules" ## Subtasks - [ ] Identify the duplicate `@then('the rendered text should contain "{text}"')` step in both `tui_thought_block_steps.py` and `tui_first_run_steps.py` - [ ] Decide on resolution strategy: domain-prefix rename or consolidation into a shared steps module - [ ] Apply the chosen fix (rename or consolidate) to eliminate the duplicate registration - [ ] Update all `.feature` files referencing the old step pattern to use the new pattern - [ ] Run `behave --dry-run` to confirm zero `AmbiguousStep` errors for this pattern - [ ] Run `nox -s unit_tests` to confirm the quality gate passes - [ ] Run full `nox` suite and confirm all sessions pass - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## Definition of Done - [ ] The duplicate `@then('the rendered text should contain "{text}"')` step pattern is eliminated - [ ] All affected `.feature` files updated to use the renamed or consolidated step pattern - [ ] `nox -s unit_tests` runs to completion with no `AmbiguousStep` crash - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] 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 --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.2.0 milestone 2026-04-03 00:03:04 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

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

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Label compliance fix applied:

  • Removed conflicting orphaned labels and ensured valid labels are set
  • Reason: Per CONTRIBUTING.md, each issue must have exactly one State/*, Type/*, and Priority/* label using the valid label set.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Label compliance fix applied: - Removed conflicting orphaned labels and ensured valid labels are set - Reason: Per CONTRIBUTING.md, each issue must have exactly one `State/*`, `Type/*`, and `Priority/*` label using the valid label set. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

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

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#1864
No description provided.