From 4b58bb719a5a37e1e99f65e490fc513192cbe092 Mon Sep 17 00:00:00 2001 From: Esoteric Enderman Date: Wed, 30 Oct 2024 23:23:09 +0000 Subject: [PATCH] Modularise message manager tests --- .../library/messages/MessageManagerTest.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/messages/MessageManagerTest.kt b/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/messages/MessageManagerTest.kt index 27af5a8..c1815fa 100644 --- a/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/messages/MessageManagerTest.kt +++ b/lib/src/test/kotlin/foundation/esoteric/minecraft/plugins/library/messages/MessageManagerTest.kt @@ -3,19 +3,29 @@ package foundation.esoteric.minecraft.plugins.library.messages import be.seeseemelk.mockbukkit.MockBukkit import foundation.esoteric.minecraft.plugins.library.TestPlugin import java.io.File +import kotlin.test.AfterTest +import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertTrue class MessageManagerTest { - @Test fun savesMessagesResource() { + + private var plugin: TestPlugin? = null + private var messageManager: MessageManager? = null + + @BeforeTest fun mockMessageManager() { MockBukkit.mock() - val plugin = MockBukkit.load(TestPlugin::class.java) + plugin = MockBukkit.load(TestPlugin::class.java) - val messageManager = MessageManager(plugin) + messageManager = MessageManager(plugin!!) + } - val messagesFolder = File(plugin.dataFolder, "messages") + @Test fun savesMessagesResource() { + val messagesFolder = File(plugin!!.dataFolder, "messages") assertTrue(messagesFolder.exists()) + } + @AfterTest fun unmockMessageManager() { MockBukkit.unmock() } }