Skip to content

[Tests] Improve statistic package test coverage and add missing @DisplayName annotations - #123

Closed
DiamondDagger590 wants to merge 1 commit into
developfrom
claude/eager-thompson-7q1sgx
Closed

DiamondDagger590 wants to merge 1 commit into
developfrom
claude/eager-thompson-7q1sgx

Conversation

@DiamondDagger590

@DiamondDagger590 DiamondDagger590 commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • StatisticCacheTest: Added @DisplayName annotations to all 6 existing tests and added 8 new tests covering previously-untested branches:

    • Multi-player isolation during invalidate(uuid) — verifies other players' entries are unaffected
    • Put-overwrite behavior — verifies updating an existing entry replaces the value
    • Invalidate on empty cache — verifies no error when invalidating with no entries
    • Size after removal — verifies size() reflects invalidations
    • Cross-player key isolation on invalidate(uuid, key) — verifies other players with the same key are unaffected
    • Mixed statistic types — verifies different StatisticType values can coexist and be retrieved correctly
  • StatisticRegistryTest: Added @DisplayName annotations to 10 existing tests that were missing them, bringing the file into full compliance with project conventions

  • StatisticEntryTest: Added 4 new tests:

    • Empty set edge case for getAsSetString — verifies an empty Set<String> returns an empty unmodifiable copy
    • Three inequality branch tests for equals — different keys, different types, different values

Test plan

  • All tests follow methodUnderTest_expectedOutcome_whenCondition naming convention
  • All tests have @DisplayName annotations
  • All tests have at least one assertion
  • No MockBukkit needed — only Bukkit value types (NamespacedKey) used
  • RegistryResetExtension used correctly in StatisticRegistryTest
  • Passed review-testing audit with no blocking concerns

Note: ./gradlew test could not be run due to maven.devs.beer returning HTTP 522 (server down), which blocks resolution of api-itemsadder, Mythic-Dist, ModelEngine, and citizens-main dependencies. These are unrelated compileOnly dependencies — the changed test files do not import or depend on any of them.

🤖 Generated with Claude Code

https://claude.ai/code/session_018kcndEPGbeWjYPi8ciywb8


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded coverage for statistic entries, including empty set handling and equality checks across differing keys, types, and values.
    • Added cache tests for overwriting values, invalidation behavior, cache size updates, and retrieval of correctly typed statistic values.
    • Clarified test names and descriptions for statistic registration, retrieval, listing, and validation scenarios.

…annotations

- StatisticCacheTest: Add @DisplayName to all 6 existing tests, add 8 new
  tests covering multi-player isolation on invalidate(uuid), put-overwrite
  behavior, invalidate-on-empty-cache, size-after-removal, cross-player key
  isolation, and mixed statistic types
- StatisticRegistryTest: Add @DisplayName to 10 existing tests that were
  missing annotations
- StatisticEntryTest: Add 4 new tests for empty set edge case in
  getAsSetString, and inequality branches for equals (different keys,
  different types, different values)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018kcndEPGbeWjYPi8ciywb8
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: DiamondDagger590/McCore/.coderabbit.yaml

Review profile: QUIET

Plan: Advanced

Run ID: 7e747d1c-04be-460f-90fa-e763b54af026

📥 Commits

Reviewing files that changed from the base of the PR and between 0fbf220 and 4151fd6.

📒 Files selected for processing (3)
  • src/test/java/com/diamonddagger590/mccore/statistic/StatisticEntryTest.java
  • src/test/java/com/diamonddagger590/mccore/statistic/StatisticRegistryTest.java
  • src/test/java/com/diamonddagger590/mccore/statistic/cache/StatisticCacheTest.java

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds statistic entry and cache tests, and renames registry and cache tests with descriptive display names. The changes affect test code only.

Changes

Statistic test coverage

Layer / File(s) Summary
Statistic entry assertions
src/test/java/com/diamonddagger590/mccore/statistic/StatisticEntryTest.java
New tests check empty set-string results and that entries with different keys, types, or values are not equal.
Statistic registry scenarios
src/test/java/com/diamonddagger590/mccore/statistic/StatisticRegistryTest.java
Registry tests were renamed and given display names. Their assertions are unchanged.
Statistic cache scenarios
src/test/java/com/diamonddagger590/mccore/statistic/cache/StatisticCacheTest.java
Cache tests were renamed and given display names. New tests cover invalidation, overwrites, cache size, and typed values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 4151f

The expanded statistic tests appear ready to merge after normal checks. The reported external dependency outage prevented a test run but does not indicate a defect in these changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the added statistic test coverage and missing @DisplayName annotations.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Claude finished @DiamondDagger590's task in 2m 17s —— View job


🔍 Review: No blocking issues found

Lens routing: This PR touches only src/test/java/** under the statistic package — no src/main changes — so only the review-testing lens applies; the other lenses (security, architecture, extensibility, error-handling, performance) have nothing to review here.

Summary: Pure test-quality PR — adds missing @DisplayName annotations across StatisticCacheTest and StatisticRegistryTest, and adds 12 new tests covering previously-untested edge cases in StatisticCacheTest (multi-player isolation, put-overwrite, empty-cache invalidation, mixed statistic types) and StatisticEntryTest (empty-set getAsSetString, equals inequality branches).

review-testing findings: CLEAN

  • All tests carry @DisplayName and follow the methodUnderTest_expectedOutcome_whenCondition naming convention
  • StatisticRegistryTest correctly uses RegistryResetExtension around the singleton RegistryAccess
  • StatisticCacheTest/StatisticEntryTest are plain JUnit, appropriately — neither StatisticCache nor StatisticEntry needs Bukkit server behavior beyond NamespacedKey
  • New assertions correctly exercise the record equals()/hashCode() and the Caffeine-backed cache's per-UUID isolation
  • No cross-thread logic introduced, so ManagedExecutorExtension doesn't apply here

Note on the PR description's caveat: the reported ./gradlew test failure (HTTP 522 from maven.devs.beer) blocks compileOnly dependencies (api-itemsadder, Mythic-Dist, ModelEngine, citizens-main) unrelated to these test files — this is an external repo outage, not something introduced by this change.

No action items. Ready to merge from a testing-lens perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants