mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-15 07:05:28 +01:00
Add additional test set up more idiomatically.
This commit is contained in:
parent
8f9df0294d
commit
55390952c9
@ -16,14 +16,14 @@ abstract class TestWithMockBukkit {
|
||||
protected lateinit var multiverseCore: MultiverseCore
|
||||
|
||||
@BeforeTest
|
||||
open fun setUp() {
|
||||
fun setUpMockBukkit() {
|
||||
TestingMode.enable()
|
||||
server = MockBukkit.mock()
|
||||
multiverseCore = MockBukkit.load(MultiverseCore::class.java)
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
fun tearDown() {
|
||||
fun tearDownMockBukkit() {
|
||||
MockBukkit.unmock()
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,27 @@
|
||||
package org.mvplugins.multiverse.core.config
|
||||
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mvplugins.multiverse.core.TestWithMockBukkit
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.test.*
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ConfigTest : TestWithMockBukkit() {
|
||||
|
||||
private lateinit var config : MVCoreConfig
|
||||
|
||||
@BeforeTest
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
fun setUp() {
|
||||
config = multiverseCore.getService(MVCoreConfig::class.java).takeIf { it != null } ?: run {
|
||||
throw IllegalStateException("MVCoreConfig is not available as a service") }
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun `Config load`() {
|
||||
val defaultConfig = getResourceAsText("/default_config.yml")
|
||||
assertNotNull(defaultConfig)
|
||||
File(Path.of(multiverseCore.dataFolder.absolutePath, "config.yml").absolutePathString()).writeText(defaultConfig)
|
||||
|
Loading…
Reference in New Issue
Block a user