diff --git a/build.gradle.kts b/build.gradle.kts index ae456b2..0dd4425 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { java + jacoco `java-library` `maven-publish` } @@ -17,6 +18,11 @@ dependencies { api(libs.minestom) compileOnly(libs.junit.params) compileOnly(libs.junit.api) + + testImplementation(libs.junit.api) + testImplementation(libs.junit.params) + testImplementation(libs.junit.platform.launcher) + testRuntimeOnly(libs.junit.engine) } tasks { @@ -24,6 +30,14 @@ tasks { options.encoding = "UTF-8" options.release.set(21) } + + test { + useJUnitPlatform() + jvmArgs("-Dminestom.inside-test=true") + testLogging { + events("passed", "skipped", "failed") + } + } } publishing { diff --git a/settings.gradle.kts b/settings.gradle.kts index 38a9c17..de03684 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,13 +7,17 @@ dependencyResolutionManagement { versionCatalogs { create("libs") { - version("minestom", "a1d1920a04") - version("junit-jupiter", "5.13.2") + version("minestom", "2025.07.03-1.21.5") + version("junit", "5.13.2") + version("junit.platform", "1.13.1") - library("minestom","net.minestom", "minestom-snapshots").versionRef("minestom") + library("minestom","net.minestom", "minestom").versionRef("minestom") + + library("junit.api", "org.junit.jupiter", "junit-jupiter-api").versionRef("junit") + library("junit.params", "org.junit.jupiter", "junit-jupiter-params").versionRef("junit") + library("junit.engine", "org.junit.jupiter", "junit-jupiter-engine").versionRef("junit") + library("junit.platform.launcher", "org.junit.platform", "junit-platform-launcher").versionRef("junit.platform") - library("junit-api", "org.junit.jupiter", "junit-jupiter-api").versionRef("junit-jupiter") - library("junit-params", "org.junit.jupiter", "junit-jupiter-params").versionRef("junit-jupiter") } } } diff --git a/src/test/java/net/minestom/testing/TestPlayerIntegrationTest.java b/src/test/java/net/minestom/testing/TestPlayerIntegrationTest.java new file mode 100644 index 0000000..46ae8f6 --- /dev/null +++ b/src/test/java/net/minestom/testing/TestPlayerIntegrationTest.java @@ -0,0 +1,29 @@ +package net.minestom.testing; + +import net.minestom.server.coordinate.Pos; +import net.minestom.server.entity.Player; +import net.minestom.server.instance.Instance; +import net.minestom.testing.extension.MicrotusExtension; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.Assertions.*; + +@ExtendWith(MicrotusExtension.class) +class TestPlayerIntegrationTest { + + @Test + void testCustomPlayerCreation(@NotNull Env env) { + Instance instance = env.createFlatInstance(); + assertNotNull(instance); + Player player = env.createPlayer(instance); + assertNotNull(player, "Player should not be null after creation"); + assertInstanceOf(Player.class, player, "Player should be an instance of Player class"); + assertInstanceOf(TestPlayerImpl.class, player, "Player should be an instance of TestPlayerImpl class"); + assertEquals(instance, player.getInstance(), "Player should be in the created instance"); + assertEquals(Pos.ZERO, player.getPosition(), "Player should start at position (0, 0, 0)"); + assertEquals("RandName", player.getUsername(), "Player should have a random name"); + } + +} \ No newline at end of file