Begin testing

This commit is contained in:
Bärtschi Robin 2024-06-06 22:23:29 +02:00
parent 687de6b267
commit ff00885682
4 changed files with 43 additions and 2 deletions

View File

@ -4,7 +4,7 @@ plugins {
idea
`maven-publish`
id("io.freefair.lombok") version "8.6"
id ("net.neoforged.gradle.userdev") version ("7.0.138")
id ("net.neoforged.gradle.userdev") version ("7.0.139")
}
val minecraftVersion: String by project
@ -58,6 +58,10 @@ runs {
modSource (project.sourceSets["main"])
}
create("junit") {
junit(true)
}
create("client") {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty ("forge.enabledGameTestNamespaces", modId)
@ -82,6 +86,7 @@ runs {
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll ("--mod", modId, "--all", "--output", file("src/generated/resources/").absolutePath, "--existing", file("src/main/resources/").absolutePath)
}
}
// Include resources generated by data generators.
@ -91,6 +96,15 @@ sourceSets.main.configure {
}
}
sourceSets {
test {
java {
srcDir("src/test/java")
}
resources{ srcDir("src/test/resources")}
}
}
dependencies {
// Specify the version of Minecraft to use.
@ -101,6 +115,10 @@ dependencies {
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
implementation ("net.neoforged:neoforge:${neoVersion}")
// Testing
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation("org.junit.jupiter:junit-jupiter-params")
// Example mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
@ -170,3 +188,7 @@ idea {
isDownloadSources = true
}
}
tasks.test {
useJUnitPlatform()
}

View File

@ -12,7 +12,7 @@ minecraftVersion=1.20.6
# as they do not follow standard versioning conventions.
minecraftVersionRange=[1.20.6,1.21)
# The Neo version must agree with the Minecraft version to get a valid artifact
neoVersion=20.6.100-beta
neoVersion=20.6.110-beta
# The Neo version range can use any version of Neo as bounds
neoVersionRange=[20,)
# The loader version range can only use the major version of FML as bounds

View File

@ -26,6 +26,8 @@ import robaertschi.environmenttech.menu.ETMenus;
@Mod(EnvironmentTech.MODID)
public class EnvironmentTech
{
public static final String MODID = "environmenttech";
public static final Logger LOGGER = LogUtils.getLogger();

View File

@ -0,0 +1,17 @@
package robaertschi.environmenttech.test;
import net.neoforged.testframework.conf.ClientConfiguration;
import net.neoforged.testframework.conf.FrameworkConfiguration;
import net.neoforged.testframework.impl.MutableTestFramework;
import org.lwjgl.glfw.GLFW;
import robaertschi.environmenttech.EnvironmentTech;
public class TestMain {
final MutableTestFramework framework = FrameworkConfiguration.builder(EnvironmentTech.id("tests"))
.clientConfiguration(() -> ClientConfiguration.builder()
.toggleOverlayKey(GLFW.GLFW_KEY_J)
.openManagerKey(GLFW.GLFW_KEY_N)
.build())
.build().create();
}