use of net.minecraft.gametest.framework.TestFunction in project MinecraftForge by MinecraftForge.
the class GameTestTest method generateTests.
/**
* An example game test generator.
* <p>
* A <b>game test generator</b> generates a collection of test functions.
* It is called immediately when registered to GameTestRegistry.
* <p><ul>
* <li>Must return {@code Collection<TestFunction>} (or a subclass)</li>
* <li>Must take no parameters</li>
* <li>Can be {@code static} or non-static</li>
* <p>
* WARNING: If made non-static, then it will create an instance of the class every time it is run.</li>
* </ul>
*/
@GameTestGenerator
public static List<TestFunction> generateTests() {
// An example test function, run in the default batch, with the test name "teststone", and the structure name "gametesttest.teststone" under the "gametest_test" namespace.
// No rotation, 100 ticks until the test times out if it does not fail or succeed, 0 ticks for setup time, and the actual code to run.
TestFunction testStone = new TestFunction("defaultBatch", "teststone", new ResourceLocation(MODID, "gametesttest.teststone").toString(), Rotation.NONE, 100, 0, true, helper -> {
BlockPos stonePos = new BlockPos(1, 1, 1);
// This should always assert to true, since we set it then directly check it
helper.setBlock(stonePos, Blocks.STONE);
helper.assertBlockState(stonePos, b -> b.is(Blocks.STONE), () -> "Block was not stone");
helper.succeed();
});
return List.of(testStone);
}
Aggregations