Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
java
jacoco
`java-library`
`maven-publish`
}
Expand All @@ -17,13 +18,26 @@ 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 {
compileJava {
options.encoding = "UTF-8"
options.release.set(21)
}

test {
useJUnitPlatform()
jvmArgs("-Dminestom.inside-test=true")
testLogging {
events("passed", "skipped", "failed")
}
}
}

publishing {
Expand Down
14 changes: 9 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}

}
Loading