Class GameTests
java.lang.Object
net.ixdarklord.coolcatcore.api.gametest.GameTests
Game tests from common code, the same on every loader: a test is a function given a
GameTestHelper, run in
a structure built for it, and it passes or fails. Register them while your mod constructs, by class (methods marked
GameTest) or one by one:
GameTests.register(MOD_ID, WandTests.class);
GameTests.register(MyMod.id("crate/keeps_items"), GameTestOptions.DEFAULT.withMaxTicks(40), helper -> {
helper.setBlock(1, 1, 1, MyBlocks.CRATE.get());
...
helper.succeed();
});
Tests are added to the game only when it's run to test (isEnabled()): in a development environment, or
with -Dcoolcatlib.gametest=true (or the loader's own switch, -Dfabric-api.gametest or
-Dneoforge.gameTestServer=true). Then:
- in game,
/test run <tests>runs them by id or pattern (/test run mymod:*runs all of a mod's), and/test runfailedthose that failed; - a game test server runs them all and exits, failing if a required one did: on Fabric a dedicated server with
-Dfabric-api.gametest, on NeoForge thegameTestServerrun.
data/<ns>/structure/<path>.nbt, saved with a structure block or
the test block); without one, tests run on GameTestOptions.PLATFORM.-
Method Summary
Modifier and TypeMethodDescriptionstatic List<net.minecraft.resources.Identifier> all()Every test registered so far.static booleanWhether tests are added to the game this run (see the class description).static List<net.minecraft.resources.Identifier> Registers everyGameTestmethod of a class, as<modid>:<class>/<method>.static voidregister(net.minecraft.resources.Identifier id, Consumer<net.minecraft.gametest.framework.GameTestHelper> test) Registers one test.static voidregister(net.minecraft.resources.Identifier id, GameTestOptions options, Consumer<net.minecraft.gametest.framework.GameTestHelper> test) Registers one test with its options.
-
Method Details
-
register
public static void register(net.minecraft.resources.Identifier id, Consumer<net.minecraft.gametest.framework.GameTestHelper> test) Registers one test. Call while your mod constructs; its id's namespace must be your mod id. -
register
public static void register(net.minecraft.resources.Identifier id, GameTestOptions options, Consumer<net.minecraft.gametest.framework.GameTestHelper> test) Registers one test with its options. Call while your mod constructs; its id's namespace must be your mod id. -
register
-
isEnabled
public static boolean isEnabled()Whether tests are added to the game this run (see the class description). -
all
Every test registered so far.
-