do not mock every time

This commit is contained in:
alexcrea 2025-04-27 23:49:05 +02:00
parent 5d427074a9
commit 02dea53a69
No known key found for this signature in database
GPG key ID: 027DD67D2D3280C5

View file

@ -1,7 +1,9 @@
package xyz.alexcrea.cuanvil.tests;
import io.delilaheve.CustomAnvil;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.mockbukkit.mockbukkit.MockBukkit;
import org.mockbukkit.mockbukkit.ServerMock;
@ -13,13 +15,16 @@ import java.util.List;
public abstract class DefaultCustomAnvilTest {
protected ServerMock server;
protected static ServerMock server;
protected CustomAnvil plugin;
@BeforeAll
public static void setupMock() {
server = MockBukkit.mock();
}
@BeforeEach
public void setUp() {
// Start the mock server
server = MockBukkit.mock();
// Load your plugin
plugin = MockBukkit.load(CustomAnvil.class);
// Continue initialization of the plugin
@ -28,9 +33,6 @@ public abstract class DefaultCustomAnvilTest {
@AfterEach
public void tearDown() {
// Stop the mock server
MockBukkit.unmock();
// Unregister enchantments
List<CAEnchantment> toUnregister = new ArrayList<>(
CAEnchantmentRegistry.getInstance().values()
@ -40,6 +42,13 @@ public abstract class DefaultCustomAnvilTest {
CAEnchantmentRegistry.getInstance().unregister(caEnchantment);
}
server.getPluginManager().disablePlugin(plugin);
}
@AfterAll
public static void tearDownMock() {
// Stop the mock server
MockBukkit.unmock();
}
}