mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-16 05:02:19 +01:00
Make separate module for testing framework (#1428)
This commit is contained in:
parent
5537faabac
commit
0b0dc83ffe
@ -42,12 +42,8 @@ tasks {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Junit Testing Framework
|
||||
testImplementation(libs.junit.api)
|
||||
testImplementation(libs.junit.params)
|
||||
testRuntimeOnly(libs.junit.engine)
|
||||
testImplementation(libs.junit.suite.api)
|
||||
testRuntimeOnly(libs.junit.suite.engine)
|
||||
// Testing Framework
|
||||
testImplementation(project(mapOf("path" to ":testing")))
|
||||
// Only here to ensure J9 module support for extensions and our classloaders
|
||||
testCompileOnly(libs.mockito.core)
|
||||
|
||||
|
@ -20,4 +20,5 @@ rootProject.name = "Minestom"
|
||||
include("code-generators")
|
||||
include("jmh-benchmarks")
|
||||
include("jcstress-tests")
|
||||
include("demo")
|
||||
include("demo")
|
||||
include("testing")
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.advancements;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,11 +0,0 @@
|
||||
package net.minestom.server.api;
|
||||
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
final class EnvBefore implements BeforeEachCallback {
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) {
|
||||
System.setProperty("minestom.viewable-packet", "false");
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package net.minestom.server.api;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.InvocationInterceptor;
|
||||
import org.junit.jupiter.api.extension.ReflectiveInvocationContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
final class EnvCleaner implements InvocationInterceptor {
|
||||
@Override
|
||||
public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
|
||||
invocation.proceed();
|
||||
EnvImpl env = (EnvImpl) invocationContext.getArguments().get(0);
|
||||
env.cleanup();
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package net.minestom.server.api;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
|
||||
|
||||
final class EnvParameterResolver extends TypeBasedParameterResolver<Env> {
|
||||
@Override
|
||||
public Env resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
|
||||
throws ParameterResolutionException {
|
||||
return new EnvImpl(MinecraftServer.updateProcess());
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package net.minestom.server.api;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@ExtendWith(EnvParameterResolver.class)
|
||||
@ExtendWith(EnvBefore.class)
|
||||
@ExtendWith(EnvCleaner.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface EnvTest {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.collision;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.collision;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.collision;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.collision;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.command;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.command.builder.suggestion.SuggestionEntry;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.collision.BoundingBox;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.event.item.PickupItemEvent;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.network.packet.server.play.EntityMetaDataPacket;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.event.entity.EntityTickEvent;
|
||||
import net.minestom.server.network.packet.server.play.DestroyEntitiesPacket;
|
||||
@ -12,7 +12,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.waitUntilCleared;
|
||||
import static net.minestom.testing.TestUtils.waitUntilCleared;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@EnvTest
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.play.EntityTeleportPacket;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.network.packet.server.play.SpawnEntityPacket;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.event.player.PlayerChangeHeldSlotEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity.ai;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity.player;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.entity.player;
|
||||
|
||||
import net.minestom.server.api.Collector;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Collector;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.minestom.server.entity.player;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.api.Collector;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.server.api.TestConnection;
|
||||
import net.minestom.testing.Collector;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.testing.TestConnection;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Player;
|
||||
@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.waitUntilCleared;
|
||||
import static net.minestom.testing.TestUtils.waitUntilCleared;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class EventNodeMapTest {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.network.packet.server.play.ChunkDataPacket;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.generator.GenerationUnit;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.tag.Tag;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.event.player.PlayerTickEvent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.waitUntilCleared;
|
||||
import static net.minestom.testing.TestUtils.waitUntilCleared;
|
||||
|
||||
@EnvTest
|
||||
public class InstanceUnregisterIntegrationTest {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.inventory;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.event.item.ItemDropEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.inventory;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.EquipmentSlot;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.inventory.click.integration;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.inventory.InventoryPreClickEvent;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.inventory.click.integration;
|
||||
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.inventory.InventoryPreClickEvent;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.inventory.click.integration;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.inventory.InventoryPreClickEvent;
|
||||
|
@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ItemAttributeTest {
|
||||
|
@ -3,7 +3,7 @@ package net.minestom.server.item;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ItemBlockTest {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.snapshot;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.snapshot;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.snapshot;
|
||||
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
@ -2,7 +2,7 @@ package net.minestom.server.tag;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package net.minestom.server.tag;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
|
@ -6,8 +6,8 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.server.api.TestUtils.waitUntilCleared;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.waitUntilCleared;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagListTest {
|
||||
|
@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
|
||||
|
@ -4,7 +4,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagPathTest {
|
||||
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagRecordTest {
|
||||
|
@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagStructureTest {
|
||||
|
@ -3,7 +3,7 @@ package net.minestom.server.tag;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagUpdateTest {
|
||||
|
@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
|
||||
import static net.minestom.testing.TestUtils.assertEqualsSNBT;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TagViewTest {
|
||||
|
@ -5,8 +5,8 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.translation.GlobalTranslator;
|
||||
import net.kyori.adventure.translation.TranslationRegistry;
|
||||
import net.minestom.server.adventure.MinestomAdventure;
|
||||
import net.minestom.server.api.Env;
|
||||
import net.minestom.server.api.EnvTest;
|
||||
import net.minestom.testing.Env;
|
||||
import net.minestom.testing.EnvTest;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.network.packet.server.play.SystemChatPacket;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
26
testing/build.gradle.kts
Normal file
26
testing/build.gradle.kts
Normal file
@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("java-library")
|
||||
}
|
||||
|
||||
group = "net.minestom.testing"
|
||||
version = "1.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(url = "https://jitpack.io")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Minestom API
|
||||
api(project(mapOf("path" to ":")))
|
||||
// Junit Testing Framework
|
||||
api(libs.junit.api)
|
||||
api(libs.junit.params)
|
||||
api(libs.junit.suite.api)
|
||||
runtimeOnly(libs.junit.engine)
|
||||
runtimeOnly(libs.junit.suite.engine)
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.minestom.server.ServerProcess;
|
||||
import net.minestom.server.coordinate.Pos;
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.minestom.server.ServerProcess;
|
||||
import net.minestom.server.event.Event;
|
43
testing/src/main/java/net/minestom/testing/EnvTest.java
Normal file
43
testing/src/main/java/net/minestom/testing/EnvTest.java
Normal file
@ -0,0 +1,43 @@
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
import org.junit.jupiter.api.extension.support.TypeBasedParameterResolver;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@ExtendWith(EnvTest.EnvParameterResolver.class)
|
||||
@ExtendWith(EnvTest.EnvBefore.class)
|
||||
@ExtendWith(EnvTest.EnvCleaner.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface EnvTest {
|
||||
|
||||
final class EnvBefore implements BeforeEachCallback {
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) {
|
||||
System.setProperty("minestom.viewable-packet", "false");
|
||||
}
|
||||
}
|
||||
|
||||
final class EnvCleaner implements InvocationInterceptor {
|
||||
@Override
|
||||
public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
|
||||
invocation.proceed();
|
||||
EnvImpl env = (EnvImpl) invocationContext.getArguments().get(0);
|
||||
env.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
final class EnvParameterResolver extends TypeBasedParameterResolver<Env> {
|
||||
@Override
|
||||
public Env resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
|
||||
throws ParameterResolutionException {
|
||||
return new EnvImpl(MinecraftServer.updateProcess());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.kyori.adventure.translation.GlobalTranslator;
|
||||
import net.minestom.server.ServerProcess;
|
@ -1,4 +1,4 @@
|
||||
package net.minestom.server.api;
|
||||
package net.minestom.testing;
|
||||
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTException;
|
Loading…
Reference in New Issue
Block a user