refactor(testing): rename tdd_bug/tdd_bug_N tags to tdd_issue/tdd_issue_N across Behave and Robot Framework #965

Closed
opened 2026-03-16 02:35:11 +00:00 by freemo · 3 comments
Owner

Metadata

  • Commit Message: refactor(testing): rename tdd_bug/tdd_bug_N tags to tdd_issue/tdd_issue_N
  • Branch: refactor/m3-tdd-tag-rename

Background and Context

The current TDD tag system uses @tdd_bug and @tdd_bug_<N> as the filter and issue-reference tags. However, the TDD expected-failure workflow is not limited to bug fixes — it applies equally to any issue type where a test is written before the implementation (features, tasks, refactors, etc.). The _bug suffix is misleading and artificially narrows the perceived scope of the TDD workflow.

This issue renames the tags to @tdd_issue and @tdd_issue_<N> to accurately reflect that the TDD tagging system applies to any Forgejo issue, not just bugs. The @tdd_expected_fail tag is unchanged — it already has a generic name.

The three-tag system after this rename:

Tag Purpose Lifecycle
@tdd_issue Generic filter tag. Present on all TDD tests. Used to list, filter, and count TDD tests across the codebase. Permanent — never removed.
@tdd_issue_<N> Issue reference tag (e.g., @tdd_issue_123). Links the test to the specific Forgejo issue it captures. N is the issue number. Permanent — never removed. Serves as a regression reference.
@tdd_expected_fail Behavioral switch. When present, the test framework inverts the test result. Temporary — removed when the issue is implemented/fixed.

Expected Behavior

All references to tdd_bug and tdd_bug_<N> are replaced with tdd_issue and tdd_issue_<N> respectively. The tag validation logic, test infrastructure, documentation, and all existing tagged test files are updated consistently. Normal test execution is completely unaffected apart from the name change.

Acceptance Criteria

  • features/environment.py: validate_tdd_tags() and should_invert_result() updated to recognize @tdd_issue / @tdd_issue_<N> instead of @tdd_bug / @tdd_bug_<N>
  • robot/tdd_expected_fail_listener.py: Listener v3 tag validation updated for tdd_issue / tdd_issue_<N>
  • All existing .feature files with @tdd_bug or @tdd_bug_<N> tags renamed to @tdd_issue / @tdd_issue_<N>
  • All existing .robot files with tdd_bug or tdd_bug_<N> tags renamed to tdd_issue / tdd_issue_<N>
  • Tag validation test files updated: features/testing/tdd_tag_validation.feature, robot/tdd_tag_validation.robot, robot/helper_tdd_tag_validation.py, and all fixture files under robot/fixtures/
  • CONTRIBUTING.md updated: "TDD Bug Test Tags" section renamed and all tdd_bug references changed to tdd_issue; "Bug Fix Workflow" section updated to reference tdd_issue tags
  • noxfile.py updated: any --include tdd_bug or --tag tdd_bug filter references changed to tdd_issue
  • nox -s unit_tests passes
  • nox -s integration_tests passes
  • ruff check and ruff format pass
  • Coverage >= 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks below 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.

Subtasks

  • Code: Update validate_tdd_tags() in features/environment.py — change all tdd_bug pattern matching to tdd_issue
  • Code: Update should_invert_result() and apply_tdd_inversion() in features/environment.py — change tag references
  • Code: Update robot/tdd_expected_fail_listener.py — change all tdd_bug pattern matching to tdd_issue in start_test and end_test hooks
  • Code: Rename tags in all existing Behave .feature files (features/tdd_*.feature)
  • Code: Rename tags in all existing Robot .robot files (robot/tdd_*.robot)
  • Code: Update all tag validation test files and fixtures
  • Code: Update noxfile.py filter/include references
  • Docs: Update CONTRIBUTING.md — rename section, update all tag references and examples
  • Quality: Verify nox passes (all default sessions including benchmark), fix any errors
  • Quality: Verify coverage >= 97% via nox -s coverage_report
## Metadata - **Commit Message**: `refactor(testing): rename tdd_bug/tdd_bug_N tags to tdd_issue/tdd_issue_N` - **Branch**: `refactor/m3-tdd-tag-rename` ## Background and Context The current TDD tag system uses `@tdd_bug` and `@tdd_bug_<N>` as the filter and issue-reference tags. However, the TDD expected-failure workflow is not limited to bug fixes — it applies equally to any issue type where a test is written before the implementation (features, tasks, refactors, etc.). The `_bug` suffix is misleading and artificially narrows the perceived scope of the TDD workflow. This issue renames the tags to `@tdd_issue` and `@tdd_issue_<N>` to accurately reflect that the TDD tagging system applies to **any** Forgejo issue, not just bugs. The `@tdd_expected_fail` tag is unchanged — it already has a generic name. The three-tag system after this rename: | Tag | Purpose | Lifecycle | |-----|---------|-----------| | `@tdd_issue` | Generic filter tag. Present on **all** TDD tests. Used to list, filter, and count TDD tests across the codebase. | **Permanent** — never removed. | | `@tdd_issue_<N>` | Issue reference tag (e.g., `@tdd_issue_123`). Links the test to the specific Forgejo issue it captures. N is the issue number. | **Permanent** — never removed. Serves as a regression reference. | | `@tdd_expected_fail` | Behavioral switch. When present, the test framework inverts the test result. | **Temporary** — removed when the issue is implemented/fixed. | ## Expected Behavior All references to `tdd_bug` and `tdd_bug_<N>` are replaced with `tdd_issue` and `tdd_issue_<N>` respectively. The tag validation logic, test infrastructure, documentation, and all existing tagged test files are updated consistently. Normal test execution is completely unaffected apart from the name change. ## Acceptance Criteria - [x] `features/environment.py`: `validate_tdd_tags()` and `should_invert_result()` updated to recognize `@tdd_issue` / `@tdd_issue_<N>` instead of `@tdd_bug` / `@tdd_bug_<N>` - [x] `robot/tdd_expected_fail_listener.py`: Listener v3 tag validation updated for `tdd_issue` / `tdd_issue_<N>` - [x] All existing `.feature` files with `@tdd_bug` or `@tdd_bug_<N>` tags renamed to `@tdd_issue` / `@tdd_issue_<N>` - [x] All existing `.robot` files with `tdd_bug` or `tdd_bug_<N>` tags renamed to `tdd_issue` / `tdd_issue_<N>` - [x] Tag validation test files updated: `features/testing/tdd_tag_validation.feature`, `robot/tdd_tag_validation.robot`, `robot/helper_tdd_tag_validation.py`, and all fixture files under `robot/fixtures/` - [x] `CONTRIBUTING.md` updated: "TDD Bug Test Tags" section renamed and all `tdd_bug` references changed to `tdd_issue`; "Bug Fix Workflow" section updated to reference `tdd_issue` tags - [x] `noxfile.py` updated: any `--include tdd_bug` or `--tag tdd_bug` filter references changed to `tdd_issue` - [x] `nox -s unit_tests` passes - [x] `nox -s integration_tests` passes - [x] `ruff check` and `ruff format` pass - [x] Coverage >= 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks below 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. ## Subtasks - [x] Code: Update `validate_tdd_tags()` in `features/environment.py` — change all `tdd_bug` pattern matching to `tdd_issue` - [x] Code: Update `should_invert_result()` and `apply_tdd_inversion()` in `features/environment.py` — change tag references - [x] Code: Update `robot/tdd_expected_fail_listener.py` — change all `tdd_bug` pattern matching to `tdd_issue` in `start_test` and `end_test` hooks - [x] Code: Rename tags in all existing Behave `.feature` files (`features/tdd_*.feature`) - [x] Code: Rename tags in all existing Robot `.robot` files (`robot/tdd_*.robot`) - [x] Code: Update all tag validation test files and fixtures - [x] Code: Update `noxfile.py` filter/include references - [x] Docs: Update `CONTRIBUTING.md` — rename section, update all tag references and examples - [x] Quality: Verify `nox` passes (all default sessions including benchmark), fix any errors - [x] Quality: Verify coverage >= 97% via `nox -s coverage_report`
freemo added this to the v3.2.0 milestone 2026-03-16 02:35:20 +00:00
Author
Owner

PM Triage — Day 36

Actions taken:

  • Assignee: → @hurui200320 (mechanical rename across test files — Rui's speed suits this well)
  • State: Verified (the tag rename is clearly scoped)

Dependencies:

  • Depends on: #628 (Robot Framework tdd_expected_fail listener) — must be merged first, as it established the tag infrastructure being renamed
  • Blocks: #966 (CI enforcement uses the new tag names)
  • Coordinates with: #629 (TDD quality gate — should use the new tag names)

Ordering: #965 should be completed before #966 starts, since #966's CI enforcement script will validate the renamed tags.

@hurui200320 — This is a straightforward rename across all .feature and .robot files plus the tag infrastructure code. Use search-and-replace. Make sure CONTRIBUTING.md is also updated. Coordinate with @CoreRasurae on #966 timing.


PM triage comment — Day 36

## PM Triage — Day 36 **Actions taken:** - **Assignee**: → @hurui200320 (mechanical rename across test files — Rui's speed suits this well) - **State**: Verified (the tag rename is clearly scoped) **Dependencies:** - **Depends on**: #628 (Robot Framework `tdd_expected_fail` listener) — must be merged first, as it established the tag infrastructure being renamed - **Blocks**: #966 (CI enforcement uses the new tag names) - **Coordinates with**: #629 (TDD quality gate — should use the new tag names) **Ordering:** #965 should be completed before #966 starts, since #966's CI enforcement script will validate the renamed tags. @hurui200320 — This is a straightforward rename across all `.feature` and `.robot` files plus the tag infrastructure code. Use search-and-replace. Make sure `CONTRIBUTING.md` is also updated. Coordinate with @CoreRasurae on #966 timing. --- *PM triage comment — Day 36*
Member

Implementation Notes

Scope of Changes

Renamed all tdd_bug / tdd_bug_<N> tag references to tdd_issue / tdd_issue_<N> across the entire codebase. The @tdd_expected_fail tag is unchanged as specified.

Infrastructure Code Changes

features/environment.py:

  • Renamed regex _TDD_BUG_N_RE_TDD_ISSUE_N_RE (pattern updated to tdd_issue_\d+)
  • Renamed variables has_tdd_bughas_tdd_issue, has_tdd_bug_nhas_tdd_issue_n, bug_n_tagsissue_n_tags
  • Updated all error messages to reference @tdd_issue / @tdd_issue_<N>
  • Updated comments and section headers: "TDD Bug Test Tags" → "TDD Issue Test Tags"
  • Updated CONTRIBUTING.md cross-references in error messages

robot/tdd_expected_fail_listener.py:

  • Same regex, variable, and error message renames as environment.py
  • Updated docstrings: "TDD bug-capture" → "TDD issue-capture"
  • Updated tag validation error messages consistently

Test Files Updated

Behave .feature files (33 files):

  • All @tdd_bug@tdd_issue and @tdd_bug_<N>@tdd_issue_<N> tags renamed
  • Feature documentation headers updated ("TDD Bug #NNN" → "TDD Issue #NNN")

Robot .robot files (29 files):

  • All [Tags] entries renamed: tdd_bugtdd_issue, tdd_bug_<N>tdd_issue_<N>
  • Documentation headers updated

Tag validation test infrastructure:

  • features/testing/tdd_tag_validation.feature: All tag references and test data updated
  • features/steps/tdd_tag_validation_steps.py: Mock scenario tags updated
  • robot/tdd_tag_validation.robot: Test names, commands, and expected outputs updated
  • robot/helper_tdd_tag_validation.py: Function names, command dispatch keys, fixture references, and output strings all updated

Robot fixture files renamed:

  • robot/fixtures/tdd_bug_alone.robotrobot/fixtures/tdd_issue_alone.robot
  • robot/fixtures/tdd_missing_tdd_bug.robotrobot/fixtures/tdd_missing_tdd_issue.robot
  • robot/fixtures/tdd_expected_fail_missing_bug_n.robotrobot/fixtures/tdd_expected_fail_missing_issue_n.robot
  • All fixture content (tags, docs, test names) updated consistently

Documentation Changes

CONTRIBUTING.md:

  • Section "TDD Bug Test Tags" renamed to "TDD Issue Test Tags"
  • Anchor link updated: #tdd-bug-test-tags#tdd-issue-test-tags
  • Tag table, examples, and validation rules all updated
  • "Bug Fix Workflow" section references updated to use @tdd_issue tags

noxfile.py:

  • No tdd_bug tag filter references existed (verified empty)
  • Updated 2 comment references: "TDD bug-capture" → "TDD issue-capture" and "TDD Bug Test Tags" → "TDD Issue Test Tags"

Decisions

  1. CHANGELOG.md and docs/timeline.md left unchanged — these are historical records that document what tags were named at the time those entries were written.
  2. Fixture file renames — Renamed fixture files to match their content since helper_tdd_tag_validation.py references fixtures by filename, and the tdd_bugtdd_issue replacement in the helper code would break the reference otherwise.
  3. Test case names in fixtures — Updated to reflect new tag names (e.g., "TDD Bug Tag Alone Is Valid" → "TDD Issue Tag Alone Is Valid") since these are referenced by exact string match in the helper.
  4. Descriptive function/command names — Renamed function names like cmd_tdd_bug_alone_validcmd_tdd_issue_alone_valid and command dispatch keys like "tdd-bug-alone-valid""tdd-issue-alone-valid" for consistency.
  5. References to actual bugs (e.g., "bug #797", "bug still exists", "Bug appears to be fixed") left unchanged — these refer to the actual bugs being tested, not the tag naming.

Quality Gates

  • nox (full suite, 11 sessions): All pass
  • Coverage: 98% (threshold 97%)
  • 480 features, 12,565 Behave scenarios, 48,061 steps: All pass
  • 1,775 integration tests: All pass
  • 55 e2e tests: All pass
  • Benchmarks: Pass
## Implementation Notes ### Scope of Changes Renamed all `tdd_bug` / `tdd_bug_<N>` tag references to `tdd_issue` / `tdd_issue_<N>` across the entire codebase. The `@tdd_expected_fail` tag is unchanged as specified. ### Infrastructure Code Changes **`features/environment.py`:** - Renamed regex `_TDD_BUG_N_RE` → `_TDD_ISSUE_N_RE` (pattern updated to `tdd_issue_\d+`) - Renamed variables `has_tdd_bug` → `has_tdd_issue`, `has_tdd_bug_n` → `has_tdd_issue_n`, `bug_n_tags` → `issue_n_tags` - Updated all error messages to reference `@tdd_issue` / `@tdd_issue_<N>` - Updated comments and section headers: "TDD Bug Test Tags" → "TDD Issue Test Tags" - Updated CONTRIBUTING.md cross-references in error messages **`robot/tdd_expected_fail_listener.py`:** - Same regex, variable, and error message renames as `environment.py` - Updated docstrings: "TDD bug-capture" → "TDD issue-capture" - Updated tag validation error messages consistently ### Test Files Updated **Behave `.feature` files (33 files):** - All `@tdd_bug` → `@tdd_issue` and `@tdd_bug_<N>` → `@tdd_issue_<N>` tags renamed - Feature documentation headers updated ("TDD Bug #NNN" → "TDD Issue #NNN") **Robot `.robot` files (29 files):** - All `[Tags]` entries renamed: `tdd_bug` → `tdd_issue`, `tdd_bug_<N>` → `tdd_issue_<N>` - Documentation headers updated **Tag validation test infrastructure:** - `features/testing/tdd_tag_validation.feature`: All tag references and test data updated - `features/steps/tdd_tag_validation_steps.py`: Mock scenario tags updated - `robot/tdd_tag_validation.robot`: Test names, commands, and expected outputs updated - `robot/helper_tdd_tag_validation.py`: Function names, command dispatch keys, fixture references, and output strings all updated **Robot fixture files renamed:** - `robot/fixtures/tdd_bug_alone.robot` → `robot/fixtures/tdd_issue_alone.robot` - `robot/fixtures/tdd_missing_tdd_bug.robot` → `robot/fixtures/tdd_missing_tdd_issue.robot` - `robot/fixtures/tdd_expected_fail_missing_bug_n.robot` → `robot/fixtures/tdd_expected_fail_missing_issue_n.robot` - All fixture content (tags, docs, test names) updated consistently ### Documentation Changes **`CONTRIBUTING.md`:** - Section "TDD Bug Test Tags" renamed to "TDD Issue Test Tags" - Anchor link updated: `#tdd-bug-test-tags` → `#tdd-issue-test-tags` - Tag table, examples, and validation rules all updated - "Bug Fix Workflow" section references updated to use `@tdd_issue` tags **`noxfile.py`:** - No `tdd_bug` tag filter references existed (verified empty) - Updated 2 comment references: "TDD bug-capture" → "TDD issue-capture" and "TDD Bug Test Tags" → "TDD Issue Test Tags" ### Decisions 1. **CHANGELOG.md and docs/timeline.md** left unchanged — these are historical records that document what tags were named at the time those entries were written. 2. **Fixture file renames** — Renamed fixture files to match their content since `helper_tdd_tag_validation.py` references fixtures by filename, and the `tdd_bug` → `tdd_issue` replacement in the helper code would break the reference otherwise. 3. **Test case names in fixtures** — Updated to reflect new tag names (e.g., "TDD Bug Tag Alone Is Valid" → "TDD Issue Tag Alone Is Valid") since these are referenced by exact string match in the helper. 4. **Descriptive function/command names** — Renamed function names like `cmd_tdd_bug_alone_valid` → `cmd_tdd_issue_alone_valid` and command dispatch keys like `"tdd-bug-alone-valid"` → `"tdd-issue-alone-valid"` for consistency. 5. **References to actual bugs** (e.g., "bug #797", "bug still exists", "Bug appears to be fixed") left unchanged — these refer to the actual bugs being tested, not the tag naming. ### Quality Gates - `nox` (full suite, 11 sessions): **All pass** - Coverage: **98%** (threshold 97%) - 480 features, 12,565 Behave scenarios, 48,061 steps: **All pass** - 1,775 integration tests: **All pass** - 55 e2e tests: **All pass** - Benchmarks: **Pass**
Member

Self-QA Implementation Notes (Cycle 1)

Cycle 1

Review verdict: Approve (0C/0M/0m/2n)

Review findings:
The PR was reviewed across 5 focus areas (spec compliance, bug detection, test coverage, performance/security, code quality). No critical, major, or minor issues were found. Two nits were identified:

  1. Nit — Missing test scenario for valid multiple tdd_issue_<N> tags: The test suite validates invalid multiple tdd_issue_N without tdd_issue, but lacks a corresponding valid scenario with multiple tdd_issue_N plus tdd_issue. The production code's any() logic handles this correctly, so this is a documentation/guard-rail gap only.

  2. Nit — Pre-existing Type/Bug references in unchanged context lines (informational): Some untouched lines still reference Type/Bug terminology. This is intentionally out of scope for ticket #965 which focuses on tag renaming only.

Fixes applied: None needed — PR approved on first review cycle.

Remaining Issues

  • Two nits noted above are optional improvements that could be addressed in follow-up tickets if desired. Neither affects correctness or blocks merging.
## Self-QA Implementation Notes (Cycle 1) ### Cycle 1 **Review verdict:** ✅ Approve (0C/0M/0m/2n) **Review findings:** The PR was reviewed across 5 focus areas (spec compliance, bug detection, test coverage, performance/security, code quality). No critical, major, or minor issues were found. Two nits were identified: 1. **Nit — Missing test scenario for valid multiple `tdd_issue_<N>` tags:** The test suite validates *invalid* multiple `tdd_issue_N` without `tdd_issue`, but lacks a corresponding *valid* scenario with multiple `tdd_issue_N` plus `tdd_issue`. The production code's `any()` logic handles this correctly, so this is a documentation/guard-rail gap only. 2. **Nit — Pre-existing `Type/Bug` references in unchanged context lines (informational):** Some untouched lines still reference `Type/Bug` terminology. This is intentionally out of scope for ticket #965 which focuses on tag renaming only. **Fixes applied:** None needed — PR approved on first review cycle. ### Remaining Issues - Two nits noted above are optional improvements that could be addressed in follow-up tickets if desired. Neither affects correctness or blocks merging.
hurui200320 2026-03-27 06:18:56 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#965
No description provided.