mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
do not mock every time
This commit is contained in:
parent
5d427074a9
commit
02dea53a69
1 changed files with 15 additions and 6 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
package xyz.alexcrea.cuanvil.tests;
|
package xyz.alexcrea.cuanvil.tests;
|
||||||
|
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.mockbukkit.mockbukkit.MockBukkit;
|
import org.mockbukkit.mockbukkit.MockBukkit;
|
||||||
import org.mockbukkit.mockbukkit.ServerMock;
|
import org.mockbukkit.mockbukkit.ServerMock;
|
||||||
|
|
@ -13,13 +15,16 @@ import java.util.List;
|
||||||
|
|
||||||
public abstract class DefaultCustomAnvilTest {
|
public abstract class DefaultCustomAnvilTest {
|
||||||
|
|
||||||
protected ServerMock server;
|
protected static ServerMock server;
|
||||||
protected CustomAnvil plugin;
|
protected CustomAnvil plugin;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void setupMock() {
|
||||||
|
server = MockBukkit.mock();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
// Start the mock server
|
|
||||||
server = MockBukkit.mock();
|
|
||||||
// Load your plugin
|
// Load your plugin
|
||||||
plugin = MockBukkit.load(CustomAnvil.class);
|
plugin = MockBukkit.load(CustomAnvil.class);
|
||||||
// Continue initialization of the plugin
|
// Continue initialization of the plugin
|
||||||
|
|
@ -28,9 +33,6 @@ public abstract class DefaultCustomAnvilTest {
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
// Stop the mock server
|
|
||||||
MockBukkit.unmock();
|
|
||||||
|
|
||||||
// Unregister enchantments
|
// Unregister enchantments
|
||||||
List<CAEnchantment> toUnregister = new ArrayList<>(
|
List<CAEnchantment> toUnregister = new ArrayList<>(
|
||||||
CAEnchantmentRegistry.getInstance().values()
|
CAEnchantmentRegistry.getInstance().values()
|
||||||
|
|
@ -40,6 +42,13 @@ public abstract class DefaultCustomAnvilTest {
|
||||||
CAEnchantmentRegistry.getInstance().unregister(caEnchantment);
|
CAEnchantmentRegistry.getInstance().unregister(caEnchantment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.getPluginManager().disablePlugin(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void tearDownMock() {
|
||||||
|
// Stop the mock server
|
||||||
|
MockBukkit.unmock();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue