Skip to content

Add negative game tests for all advancements#193

Merged
rubensworks merged 2 commits intomaster-1.21-ltsfrom
copilot/add-negative-game-tests-advancements
Feb 28, 2026
Merged

Add negative game tests for all advancements#193
rubensworks merged 2 commits intomaster-1.21-ltsfrom
copilot/add-negative-game-tests-advancements

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Adds negative game tests for all 5 advancements to guard against false-positive triggers, following the pattern established in CyclopsMC/IntegratedDynamics#1620.

Changes

  • assertAdvancementNotUnlocked helper — assertion that throws if an advancement is unexpectedly completed, used by all negative tests.
  • 5 negative test methods in GameTestAdvancementsIntegratedTerminals, each exercising a near-miss scenario:
Test Wrong input used
testAdvancementRootNegative minecraft:stick instead of integrateddynamics:part_display_panel
testAdvancementMenrilGlassNegative minecraft:glass instead of integratedterminals:menril_glass
testAdvancementCraftStorageTerminalNegative Craft minecraft:stick instead of integratedterminals:part_terminal_storage
testAdvancementGuiStorageTerminalNegative Open player.inventoryMenu (not a ContainerTerminalStorageBase)
testAdvancementFilterEnchantableNegative OBJECT_ITEMSTACK_ISENCHANTED operator instead of OBJECT_ITEMSTACK_ISENCHANTABLE

Each negative test follows the same shape: perform the near-miss action, then assert the advancement remains locked.

@GameTest(template = "empty", templateNamespace = "cyclopscore")
public void testAdvancementRootNegative(GameTestHelper helper) {
    ServerPlayer player = createMockServerPlayer(helper);
    player.getInventory().setItem(0, new ItemStack(
            BuiltInRegistries.ITEM.get(ResourceLocation.parse("minecraft:stick"))));
    player.inventoryMenu.broadcastChanges();
    helper.succeedWhen(() -> assertAdvancementNotUnlocked(helper, player, "integratedterminals:root"));
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
@rubensworks rubensworks marked this pull request as ready for review February 28, 2026 17:57
Copilot AI changed the title [WIP] Add negative game tests for all advancements Add negative game tests for all advancements Feb 28, 2026
@rubensworks rubensworks merged commit 68f2bf1 into master-1.21-lts Feb 28, 2026
3 checks passed
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