integration tests

This commit is contained in:
Bixilon 2022-10-17 19:57:26 +02:00
parent 0c1dd555c6
commit 162d0a97aa
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 114 additions and 42 deletions

View File

@ -14,12 +14,14 @@
import de.bixilon.kutil.os.Architectures
import de.bixilon.kutil.os.OSTypes
import de.bixilon.kutil.os.PlatformInfo
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.7.20"
id("org.openjfx.javafxplugin") version "0.0.13"
`jvm-test-suite`
application
}
@ -120,6 +122,83 @@ when (PlatformInfo.OS) {
}
}
testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
targets {
all {
testTask.configure {
filter {
isFailOnNoMatchingTests = true
}
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showStandardStreams = true
events(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR,
)
}
}
}
}
}
val integrationTest by registering(JvmTestSuite::class) {
testType.set(TestSuiteType.INTEGRATION_TEST)
useTestNG()
dependencies {
implementation(project)
// implementation("org.jetbrains.kotlin:kotlin-test:1.7.20")
implementation("de.bixilon:kutil:$kutilVersion")
}
targets {
all {
testTask.configure {
filter {
isFailOnNoMatchingTests = true
}
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showStandardStreams = true
events(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR,
)
}
options {
val options = this as TestNGOptions
options.preserveOrder = true
}
shouldRunAfter(test)
}
}
}
sources {
kotlin {
setSrcDirs(listOf("src/integration-test/kotlin"))
}
}
}
}
}
tasks.named("check") {
dependsOn(testing.suites.named("integrationTest"))
}
fun DependencyHandler.javafx(name: String) {
implementation("org.openjfx", "javafx-$name", javafxVersion, classifier = javafxNatives)
}
@ -197,6 +276,8 @@ dependencies {
// kotlin
implementation(kotlin("reflect"))
testImplementation(kotlin("test"))
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
// platform specific
@ -228,6 +309,7 @@ tasks.withType<KotlinCompile> {
application {
mainClass.set("de.bixilon.minosoft.Minosoft")
}
javafx {
version = javafxVersion
modules("javafx.controls", "javafx.fxml")

View File

@ -11,17 +11,38 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.setup.data.registries.versions
package de.bixilon.minosoft
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.minosoft.data.registries.versions.Versions
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.Test
import de.bixilon.minosoft.protocol.packets.factory.PacketTypeRegistry
import org.testng.annotations.Test
internal class VersionsSIT {
@Test
@Order(2)
internal class MinosoftSIT {
@Test(priority = 0)
fun disableGC() {
Thread {
val reference = Minosoft
reference.hashCode()
while (true) {
Thread.sleep(100L)
}
}.start()
}
@Test(priority = 1)
fun initAssetsManager() {
Minosoft.MINOSOFT_ASSETS_MANAGER.load(CountUpAndDownLatch(0))
}
@Test(priority = 2)
fun setupPacketRegistry() {
PacketTypeRegistry.init(CountUpAndDownLatch(0))
}
@Test(priority = 3)
fun loadVersionsJson() {
Versions.load(CountUpAndDownLatch(0))
}

View File

@ -11,12 +11,11 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.test.data.registries.versions
package de.bixilon.minosoft.data.registries.versions
import de.bixilon.minosoft.data.registries.versions.Versions
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import org.testng.Assert.assertEquals
import org.testng.annotations.Test
internal class VersionsIT {

View File

@ -1,30 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.setup
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.minosoft.Minosoft
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.Test
internal class MinosoftSIT {
@Test
@Order(1)
fun initAssetsManager() {
Minosoft.MINOSOFT_ASSETS_MANAGER.load(CountUpAndDownLatch(0))
print("Initialized assets manager")
}
}

View File

@ -91,7 +91,7 @@ object PacketTypeRegistry {
val innerLatch = CountUpAndDownLatch(1, latch)
for (info in ClassPath.from(classLoader).getTopLevelClassesRecursive(PacketsRoot::class.java.packageName)) {
innerLatch.inc()
DefaultThreadPool += { loadClass(s2cClassMap, s2cStateMap, c2sClassMap, c2sStateMap, info);innerLatch.dec() }
DefaultThreadPool += { loadClass(s2cClassMap, s2cStateMap, c2sClassMap, c2sStateMap, info); innerLatch.dec() }
}
innerLatch.dec()
innerLatch.await()