Bring the add/edit/remove command tests to coverage parity - #23
Merged
Conversation
AddCommand, EditCommand and RemoveCommand run the same four guards before touching an item's lore: sender must be a Player, the main hand must not be empty, the item must have meta, and the no-argument overload must send the usage string. Only AddCommandTest exercised most of them, so a regression in EditCommand's or RemoveCommand's copy of a guard would have gone unnoticed. Adds the missing cases so all three test classes cover the same guard set: - EditCommandTest and RemoveCommandTest: non-player sender, empty main hand, item without meta, and the execute(CommandSender) usage overload - AddCommandTest: item without meta, plus the player-only message assertion its non-player-sender case was missing Characterization only; no production code changed. The two new guard tests were verified against a mutated EditCommand to confirm they fail when the guard is removed. 26 tests to 35, all passing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Self-review found the parity incomplete: the three classes covered the same guards, but five of the pre-existing cases asserted only the boolean return (or matched the message with anyString()), so a guard could send the wrong text and still pass. Each of those now asserts the exact string the command sends, matching the cases added in the previous commit: - AddCommandTest: the empty-main-hand and no-argument-overload cases - EditCommandTest and RemoveCommandTest: the missing-arguments case The now-unused anyString() import is dropped from AddCommandTest. Assertions were only strengthened, never relaxed. 35 tests, all passing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
Self-review rubricScored adversarially against the diff at
Findings that were fixed during reviewThree assertion-strength gaps were found that made the parity claim weaker than it read. All were mechanical and were fixed in
No assertion was relaxed in the course of these fixes. Observations outside the diffRecorded here rather than acted on, since neither belongs in a test-expansion change.
This review was posted during a Gardener session (https://github.com/Stephenson-Software/gardener). It is a self-review by the agent that wrote the change, not an independent review. drafted by Claude on behalf of Daniel Stephenson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AddCommand,EditCommandandRemoveCommandare a parallel series: each one runs the same four guards before it touches an item's lore.Player, or"This command can only be used by a player."is sent.Material.AIR, or"You aren't holding anything."is sent.ItemStack.getItemMeta()must not returnnull, or"That item's meta information wasn't found."is sent.execute(CommandSender)overload must send that command's usage string.Only
AddCommandTestexercised most of that set.EditCommandTestandRemoveCommandTestcovered index and quoting validation but none of the four guards above, so a regression in either class's copy of a guard would have gone unnoticed until it was reported from a live server.The missing cases have been added so that all three test classes now cover the same guard set:
EditCommandTest— non-player sender, empty main hand, item without meta, and theexecute(CommandSender)usage overload (4 new tests).RemoveCommandTest— the same four cases (4 new tests).AddCommandTest— item without meta (1 new test), plus the player-only message assertion that its existing non-player-sender case was missing.These are characterization tests. No production code was changed by this PR, and no existing assertion was weakened.
The test count rises from 26 to 35.
Test plan
mvn -B test— 35 tests run, 0 failures, 0 errors, 0 skipped,BUILD SUCCESS.EditCommandTestwere confirmed non-vacuous empirically rather than by reasoning: withEditCommand'sAIRand null-meta guards mutated away,execute_rejectsWhenNotHoldingAnItemfailed andexecute_rejectsItemWithoutMetaerrored on aNullPointerException; both pass again with the guards restored. The mutation was reverted before commit, andgit statusconfirms no file undersrc/mainis modified.git diff --stat origin/main— 3 files, 90 insertions, 0 deletions, all of it test code.Notes
No documentation source of truth is affected. No command syntax, permission node, config key or user-facing behaviour was changed, so
HelpCommand.java,COMMANDS.md,USER_GUIDE.md,CONFIG.mdandCHANGELOG.mdare all still accurate as written.CHANGELOG.mdwas deliberately left untouched: this PR carries no change a user of the plugin could observe.No tracking issue exists for this work — the gap was found during triage of the existing test suite. The open backlog was deferred for the reasons below rather than picked up this cycle:
pl.defaultdeclared inDefaultCommandbut absent fromplugin.yml) — deferred. The issue asks explicitly for a maintainer decision between two defensible directions (remove the node, or declare it and routeDefaultCommandthrough the command service). Neither can be chosen autonomously.ConfigService.setConfigOptionandsendConfigListare unreachable) — deferred for the same reason. The issue states that a product decision on whether a/pl configcommand is wanted is required before any code is changed.CHANGELOG.md[Unreleased]has two### Fixedsubsections) — filed during this cycle's triage and deferred, so that this PR stays a single cohesive test-expansion change rather than mixing a documentation edit into it.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson