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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue