Skip to main content

testing

Test helpers for every subproject, built on net.minestom:testing. Source in libs/testing/.

ModuleTestSupport​

HelperWhat it does
assertToggleLeavesNothingBehind(module, env)The toggle test every module must pass: enable → disable → enable → disable, asserting after each disable that nothing is left — no listeners, commands, tasks or published services
host(env)A ModuleHost on the @EnvTest server process
standaloneHost()A ModuleHost on fresh Minestom managers, for unit tests without a server process (used by the ModuleManager tests)

Writing a module test​

@EnvTest
class WelcomeModuleTest {

@Test
void toggleLeavesNothingBehind(Env env) {
ModuleTestSupport.assertToggleLeavesNothingBehind(new WelcomeModule(), env);
}
}

The Gradle convention plugin passes the JVM flags Minestom's own tests need (-Dminestom.inside-test=true, -Dminestom.viewable-packet=false), so a module's build.gradle.kts doesn't repeat them.