Skip to content

feat(plugin): run a plugin's gametests through test with gameTests() - #117

Open
gabizou wants to merge 1 commit into
2.xfrom
feat/gametest-distribution
Open

gabizou wants to merge 1 commit into
2.xfrom
feat/gametest-distribution

Conversation

@gabizou

@gabizou gabizou commented Oct 22, 2026

Copy link
Copy Markdown
Member

Sponge | SpongeGradle

After we've added game test as a framework for Sponge's implementation to function, this PR along with the PR for SpongeGradle enables plugin developers to "drop in" game tests as an implementation dependency for a targeted Sponge version.

What's getting added

Plugin developers can now add a @GameTest and @GameTestGroup to their src/test directories to run in a few ways:

  1. Simple plugins checking for their pure SpongeAPI listener behaviors
  2. Plugins using Mixins to modify behavior of the base game on top of SpongeVanilla verifying their modified behaviors whether it's as listeners perform modifications or wiring into networking to implement anti-xray mechanics
  3. Plugins that are multi-module builds and having libraries that add on additional API's, verifying their plugin's behaviors on top of the libraries with SpongeVanilla.

The whole adoption

plugins {
    id("org.spongepowered.gradle.plugin")   // SpongeGradle, the version with gameTests()
    id("org.spongepowered.gradle.vanilla")  // VanillaGradle: GameTestHelper is a Minecraft class
}

sponge {
    apiVersion("12.0.0")
    minecraftVersion("1.21.1")
    plugin("myplugin") { /* … as before … */ }

    gameTests()                             // ← this is the adoption
}

minecraft {
    version("1.21.1")
}
// src/test/java/com/example/myplugin/test/MyPluginGameTests.java
@GameTestGroup("basics")
public final class MyPluginGameTests {

    @GameTest
    void stoneIsPlaced(final GameTestHelper helper) {
        helper.setBlock(new BlockPos(0, 1, 0), Blocks.STONE);
        helper.succeedWhen(() -> helper.assertBlockPresent(Blocks.STONE, new BlockPos(0, 1, 0)));
    }
}

Out of scope

This isn't adding a SpongeAPI equivalent for all of this, as this is still a WIP, I'd rather the functionality be added first as implementation plugins are likely to start using it first before we make SpongeAPI equivalents that can be more difficult to change in between releases.

With Sponge's distribution of its gametest modules, there are a fair bit
of wiring together of pieces to make it run properly in a plugin's
development/CI environment. This now adds in the `sponge` extension a
`gameTests()` option that does a default setup to run Game Tests on a
headless server running SpongeVanilla. The classpath includes outputs
from both the plugin's default outputs, as well as the (default defined)
test outputs (default is `src/test`).

Additional configuration of the gameTest run is available through the
extension, including library exclusion and/or inclusion.

Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
@gabizou
gabizou force-pushed the feat/gametest-distribution branch from 6ea3550 to 797ffbb Compare October 23, 2026 00:33
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.

1 participant