Skip to content

NO-JIRA: chore: add unit test naming and placement conventions - #8722

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
enxebre:worktree-update-test-skill
Jun 11, 2026
Merged

NO-JIRA: chore: add unit test naming and placement conventions#8722
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
enxebre:worktree-update-test-skill

Conversation

@enxebre

@enxebre enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Unit test functions must be named after the function under test (TestFunctionName)
  • Unit tests go next to the code they test (same package _test.go), not in test/integration/ (legacy)
  • Integration-style tests that need a cluster should use test/e2e/ or test/envtest/

Test plan

  • Verify codespell passes
  • Review skill file for clarity and completeness

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Expanded Code Formatting skill guide with enhanced test conventions, including explicit test naming standards, unit test function naming patterns, and placement guidelines.

…ing skill

- Unit test functions must be named after the function under test (TestFunctionName)
- Unit tests go next to the code they test, not in test/integration/ (legacy)
- Integration-style tests should use test/e2e/ or test/envtest/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR updates the Code Formatting skill documentation to expand mandatory test conventions. It adds a "Test naming" subsection requiring Go test names to follow the When...it should... format, introduces a "Unit test function naming" subsection specifying Test<FunctionName> naming with 1:1 mapping to functions under test, documents placement rules requiring _test.go files beside source code, and removes a previously duplicated checklist bullet about including unit tests.


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Stable And Deterministic Test Names ❌ Error SKILL.md test naming section lacks explicit requirement that test names must be stable/deterministic and never contain dynamic values (pod names, timestamps, UUIDs, node names, IP addresses, etc.). Add section to "Test naming" in SKILL.md explicitly prohibiting dynamic/generated values in test titles, clarifying that all test names (test case names, Ginkgo It/Describe/When blocks) must use static, descriptive strings that never cha...
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Structure And Quality ✅ Passed This PR is a documentation-only change updating test naming/placement conventions in .claude/skills/code-formatting/SKILL.md. There is no Ginkgo test code to review, so the check is not applicable...
Topology-Aware Scheduling Compatibility ✅ Passed PR contains only documentation changes to test naming conventions; no deployment manifests, operator code, or controllers are modified, so the topology-aware scheduling compatibility check does not...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Ginkgo e2e test added (test/e2e/v2/tests/backup_restore_test.go) shows no IPv4-specific assumptions or external connectivity requirements that would fail in IPv6-only disconnected CI environments.
No-Weak-Crypto ✅ Passed PR is a documentation-only change updating test naming conventions; contains no cryptographic code, weak crypto usage, custom crypto implementations, or non-constant-time secret comparisons.
Container-Privileges ✅ Passed The PR modifies only a markdown documentation file (.claude/skills/code-formatting/SKILL.md). The container-privileges check targets K8s/container manifests and security configurations, which are n...
No-Sensitive-Data-In-Logs ✅ Passed This is a documentation-only change (markdown file) with no logging code, passwords, tokens, API keys, PII, or sensitive data that could be logged.
Title check ✅ Passed The title accurately describes the main change: adding unit test naming and placement conventions to the Code Formatting skill documentation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added the area/ai Indicates the PR includes changes related to AI - Claude agents, Cursor rules, etc. label Jun 11, 2026
@openshift-ci
openshift-ci Bot requested review from bryan-cox and clebs June 11, 2026 17:43
@openshift-ci openshift-ci Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area labels Jun 11, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 11, 2026
@openshift-ci

openshift-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, enxebre

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification

No second-stage tests were triggered for this PR.

This can happen when:

  • The changed files don't match any pipeline_run_if_changed patterns
  • All files match pipeline_skip_if_only_changed patterns
  • No pipeline-controlled jobs are defined for the main branch

Use /test ? to see all available tests.

@enxebre

enxebre commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

/verified by @enxebre

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.59%. Comparing base (2f6b004) to head (1fe40b7).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8722   +/-   ##
=======================================
  Coverage   41.59%   41.59%           
=======================================
  Files         758      758           
  Lines       93925    93925           
=======================================
  Hits        39066    39066           
  Misses      52113    52113           
  Partials     2746     2746           
Flag Coverage Δ
cmd-support 34.96% <ø> (ø)
cpo-hostedcontrolplane 43.59% <ø> (ø)
cpo-other 43.45% <ø> (ø)
hypershift-operator 51.65% <ø> (ø)
other 31.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 11, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@enxebre: This PR has been marked as verified by @enxebre.

Details

In response to this:

/verified by @enxebre

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.claude/skills/code-formatting/SKILL.md (1)

16-38: ⚡ Quick win

Clarify "test name" refers to test case names within table-driven tests.

The section uses "test name" (line 18) without explicitly stating these are test case names within table-driven tests, not test function names. While line 57 later clarifies this, it would be clearer to specify upfront to avoid confusion.

📝 Suggested clarification
 ### Test naming
 
-**NON-NEGOTIABLE RULE**: Every Go test name MUST follow this exact format:
+**NON-NEGOTIABLE RULE**: Every Go test case name (within table-driven tests) MUST follow this exact format:
 ```go
 name: "When <condition>, it should <expected behavior>"

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/skills/code-formatting/SKILL.md around lines 16 - 38, Clarify that
"test name" in the "Test naming" section refers specifically to the name field
of individual test cases inside table-driven tests (not the Go test function
name); update the opening sentence under the "Test naming" heading to state this
explicitly and adjust the first example line (name: "When , it should
") to indicate it is the test case name in a table-driven
test, ensuring consistency with the later clarification currently present
elsewhere in the document.


</details>

<!-- cr-comment:v1:b434dcae15713e6191bc849c -->

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/skills/code-formatting/SKILL.md:

  • Around line 59-63: Docs conflict: some guides point to legacy
    test/integration/ while SKILL.md declares it deprecated. Update all docs and
    scripts to consistently treat test/integration/ as deprecated and direct
    integration-style tests to test/e2e/ or test/envtest/ (or explicitly document
    the unit vs integration vs e2e split). Concretely, edit
    .claude/skills/code-formatting/SKILL.md to state the canonical locations, and
    update docs/content/getting-started/onboarding/development.md,
    docs/.../reference.md, dr-cli.md, gcp-platform.md and any CI/test invocation
    lines (e.g., any go test .../test/integration/... commands) to point to
    test/e2e/ or test/envtest/ (or add a clear note if legacy tests remain); ensure
    the README/CONTRIBUTING includes the final placement policy.

Nitpick comments:
In @.claude/skills/code-formatting/SKILL.md:

  • Around line 16-38: Clarify that "test name" in the "Test naming" section
    refers specifically to the name field of individual test cases inside
    table-driven tests (not the Go test function name); update the opening sentence
    under the "Test naming" heading to state this explicitly and adjust the first
    example line (name: "When , it should ") to
    indicate it is the test case name in a table-driven test, ensuring consistency
    with the later clarification currently present elsewhere in the document.

</details>

<details>
<summary>🪄 Autofix (Beta)</summary>

Fix all unresolved CodeRabbit comments on this PR:

- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: Repository YAML (base), Central YAML (inherited)

**Review profile**: CHILL

**Plan**: Enterprise

**Run ID**: `69366dfc-4bb9-4454-b0f2-e7ec620199de`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 0b3300632d1314f6782feb49804eddd70a11d08e and 1fe40b7af8a69455e738938f42ea9ac22fba12ee.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `.claude/skills/code-formatting/SKILL.md`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +59 to +63
### Unit test placement

- **Always include unit tests** when creating new functions or modifying existing ones
- **Place unit tests next to the code they test** — in the same package directory, in a `_test.go` file
- **Do NOT place new tests in `test/integration/`** — this is a legacy directory. New unit tests go alongside the code under test. New integration-style tests that require a cluster should use `test/e2e/` or `test/envtest/`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for references to test/integration/ in documentation and guidance files

# Find documentation files that mention test/integration/
rg -n -C3 'test/integration' --type=md --glob '!.claude/**'

# Also check if test/integration/ directory exists and contains active tests
if [ -d "test/integration" ]; then
  echo "=== test/integration directory exists ==="
  fd -e go . test/integration | head -20
fi

Repository: openshift/hypershift

Length of output: 9461


🏁 Script executed:

#!/bin/bash
# Show the relevant lines in the skill file for exact wording/context
sed -n '45,90p' .claude/skills/code-formatting/SKILL.md | nl -ba | sed -n '1,120p'

Repository: openshift/hypershift

Length of output: 105


🏁 Script executed:

#!/bin/bash
# Show the relevant lines in the skill file for exact wording/context
sed -n '45,90p' .claude/skills/code-formatting/SKILL.md | nl -ba | sed -n '1,120p'

Repository: openshift/hypershift

Length of output: 105


🏁 Script executed:

#!/bin/bash
# Show the relevant lines in the skill file for exact wording/context
sed -n '45,90p' .claude/skills/code-formatting/SKILL.md | nl -ba | sed -n '1,120p'

Repository: openshift/hypershift

Length of output: 105


Resolve conflicting test/integration/ guidance for where to add integration coverage

.claude/skills/code-formatting/SKILL.md says test/integration/ is legacy and new integration-style tests should use test/e2e/ or test/envtest/, but several docs still direct contributors to test/integration/ (e.g., docs/content/getting-started/onboarding/development.md and .../reference.md, plus dr-cli.md/gcp-platform.md using go test .../test/integration/...). With test/integration/ containing active Go tests, this will create contradictory placement/run instructions—update/align the docs (or clarify the intended unit vs integration vs e2e split) to remove ambiguity.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/skills/code-formatting/SKILL.md around lines 59 - 63, Docs conflict:
some guides point to legacy test/integration/ while SKILL.md declares it
deprecated. Update all docs and scripts to consistently treat test/integration/
as deprecated and direct integration-style tests to test/e2e/ or test/envtest/
(or explicitly document the unit vs integration vs e2e split). Concretely, edit
.claude/skills/code-formatting/SKILL.md to state the canonical locations, and
update docs/content/getting-started/onboarding/development.md,
docs/.../reference.md, dr-cli.md, gcp-platform.md and any CI/test invocation
lines (e.g., any go test .../test/integration/... commands) to point to
test/e2e/ or test/envtest/ (or add a clear note if legacy tests remain); ensure
the README/CONTRIBUTING includes the final placement policy.

- ❌ `TestAzureIntegration`
- ❌ `TestVariousCases`

Each test function should map 1:1 to the function under test. If a function is complex enough to warrant many test cases, use table-driven tests within a single `Test<FunctionName>` function with the "When...it should..." naming for each case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth to also mention the sub-test feature golang has here.
For reference: https://go.dev/blog/subtests#table-driven-tests-using-subtests

@enxebre enxebre changed the title chore: add unit test naming and placement conventions NO-JIRA: chore: add unit test naming and placement conventions Jun 11, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 11, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@enxebre: This pull request explicitly references no jira issue.

Details

In response to this:

Summary

  • Unit test functions must be named after the function under test (TestFunctionName)
  • Unit tests go next to the code they test (same package _test.go), not in test/integration/ (legacy)
  • Integration-style tests that need a cluster should use test/e2e/ or test/envtest/

Test plan

  • Verify codespell passes
  • Review skill file for clarity and completeness

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
  • Expanded Code Formatting skill guide with enhanced test conventions, including explicit test naming standards, unit test function naming patterns, and placement guidelines.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@enxebre: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
openshift-merge-bot Bot merged commit d574e2f into openshift:main Jun 11, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/ai Indicates the PR includes changes related to AI - Claude agents, Cursor rules, etc. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants