getting unittests to work, NEOFORGE ADD SOME PROPER DOCS PLS

This commit is contained in:
Robin 2024-06-06 23:37:44 +02:00
parent ff00885682
commit f3da2f5271
2 changed files with 42 additions and 16 deletions

View File

@ -34,6 +34,19 @@ base {
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
sourceSets {
// Include resources generated by data generators.
main.configure {
resources {
srcDir("src/generated/resources")
}
}
create("junit") {
}
}
//minecraft.accessTransformers.file rootProject.file("src/main/resources/META-INF/accesstransformer.cfg")
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
@ -60,6 +73,7 @@ runs {
create("junit") {
junit(true)
unitTestSources(sourceSets["junit"])
}
create("client") {
@ -89,22 +103,11 @@ runs {
}
// Include resources generated by data generators.
sourceSets.main.configure {
resources {
srcDir("src/generated/resources")
}
}
configurations["junitImplementation"].extendsFrom(configurations.implementation.get())
sourceSets {
test {
java {
srcDir("src/test/java")
afterEvaluate {
runs["junit"].modSources = runs["junit"].modSources.get().stream().filter { it != sourceSets.main }.toList()
}
resources{ srcDir("src/test/resources")}
}
}
dependencies {
// Specify the version of Minecraft to use.
@ -115,9 +118,25 @@ 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")
sourceSets.getByName("junit") {
dependencies {
implementation(platform("org.junit:junit-bom:5.10.2"))
implementation("org.junit.jupiter:junit-jupiter-params")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
}
// "junitImplementation"(platform("org.junit:junit-bom:5.10.2"))
// "junitImplementation"("org.junit.jupiter:junit-jupiter-params")
// "junitRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine")
// Example mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime

View File

@ -0,0 +1,7 @@
package robaertschi.environmenttech.unittest;
import net.neoforged.testframework.annotation.TestGroup;
import org.junit.jupiter.api.Test;
public class TestProgressBar {
}