Abstract TestWithMockBukkit out of MockBukkitTest.

This commit is contained in:
Jeremy Wood 2023-03-07 00:20:26 -05:00
parent 00554fefc3
commit 7ad0b04787
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
2 changed files with 31 additions and 23 deletions

View File

@ -1,33 +1,12 @@
package org.mvplugins.multiverse.core
import be.seeseemelk.mockbukkit.MockBukkit
import be.seeseemelk.mockbukkit.ServerMock
import com.onarandombox.MultiverseCore.MultiverseCore
import com.onarandombox.MultiverseCore.utils.TestingMode
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertNotNull
class MockBukkitTest {
lateinit var server: ServerMock
lateinit var plugin: MultiverseCore
@BeforeTest
fun setUp() {
TestingMode.enable()
server = MockBukkit.mock()
plugin = MockBukkit.load(MultiverseCore::class.java)
}
@AfterTest
fun tearDown() {
MockBukkit.unmock()
}
open class MockBukkitTest : TestWithMockBukkit() {
@Test
fun `MockBukkit loads the plugin`() {
assertNotNull(plugin)
assertNotNull(multiverseCore)
}
}

View File

@ -0,0 +1,29 @@
package org.mvplugins.multiverse.core
import be.seeseemelk.mockbukkit.MockBukkit
import be.seeseemelk.mockbukkit.ServerMock
import com.onarandombox.MultiverseCore.MultiverseCore
import com.onarandombox.MultiverseCore.utils.TestingMode
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
/**
* Basic abstract test class that sets up MockBukkit and MultiverseCore.
*/
abstract class TestWithMockBukkit {
protected lateinit var server: ServerMock
protected lateinit var multiverseCore: MultiverseCore
@BeforeTest
fun setUp() {
TestingMode.enable()
server = MockBukkit.mock()
multiverseCore = MockBukkit.load(MultiverseCore::class.java)
}
@AfterTest
fun tearDown() {
MockBukkit.unmock()
}
}