diff --git a/build.gradle b/build.gradle index fca0ec85..f9a984b0 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,11 @@ allprojects { } } + dependencies { + testImplementation "org.junit.jupiter:junit-jupiter:${rootProject.junit_version}" + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + } + tasks.test { useJUnitPlatform() } diff --git a/fabric/build.gradle b/fabric/build.gradle index 99bb630b..940cc49a 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -52,14 +52,6 @@ tasks.shadowJar { relocate 'org.yaml.snakeyaml', 'ca.spottedleaf.moonrise.libs.org.yaml.snakeyaml' } -tasks.test { - def classPathGroups = SourceSetHelper.getClasspath(loom.mods.main, getProject()).stream() - .map(File.&getAbsolutePath) - .collect(Collectors.joining(File.pathSeparator)) - - systemProperty("fabric.classPathGroups", classPathGroups) -} - publishMods { file = remapJar.archiveFile modLoaders = ["fabric"] @@ -96,6 +88,14 @@ loom { } } +tasks.test { + def classPathGroups = SourceSetHelper.getClasspath(loom.mods.main, getProject()).stream() + .map(File.&getAbsolutePath) + .collect(Collectors.joining(File.pathSeparator)) + + systemProperty("fabric.classPathGroups", classPathGroups) +} + afterEvaluate { loom.runs.configureEach { cfg -> runConfigCommon.systemProperties.get().each { diff --git a/fabric/src/test/java/ca/spottedleaf/moonrise/fabric/MixinAuditTest.java b/fabric/src/test/java/ca/spottedleaf/moonrise/fabric/MixinAuditTest.java index c2327e5c..95a200c5 100644 --- a/fabric/src/test/java/ca/spottedleaf/moonrise/fabric/MixinAuditTest.java +++ b/fabric/src/test/java/ca/spottedleaf/moonrise/fabric/MixinAuditTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import org.spongepowered.asm.mixin.MixinEnvironment; -public class MixinAuditTest { +class MixinAuditTest { @BeforeAll static void beforeAll() { SharedConstants.tryDetectVersion(); diff --git a/gradle.properties b/gradle.properties index d71d7771..3af48c75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,7 @@ concurrentutil_version=0.0.2-SNAPSHOT yamlconfig_version=1.0.2-SNAPSHOT cloth_version=16.0.141 modmenu_version=12.0.0-beta.1 +junit_version=5.11.3 # version ids from modrinth fabric_lithium_version=QhCwdt4l neo_lithium_version=wDD955sb diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 3caf2e6b..6d20b533 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -38,6 +38,10 @@ neoForge { server() } } + unitTest { + enable() + testedMod = mods.moonrise + } } dependencies { diff --git a/neoforge/src/test/java/ca/spottedleaf/moonrise/neoforge/MixinAuditTest.java b/neoforge/src/test/java/ca/spottedleaf/moonrise/neoforge/MixinAuditTest.java new file mode 100644 index 00000000..441596a3 --- /dev/null +++ b/neoforge/src/test/java/ca/spottedleaf/moonrise/neoforge/MixinAuditTest.java @@ -0,0 +1,17 @@ +package ca.spottedleaf.moonrise.neoforge; + +import org.junit.jupiter.api.Test; +import org.spongepowered.asm.mixin.MixinEnvironment; + +class MixinAuditTest { + @Test + void auditMixins() { + final ClassLoader old = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(MixinAuditTest.class.getClassLoader()); + MixinEnvironment.getCurrentEnvironment().audit(); + } finally { + Thread.currentThread().setContextClassLoader(old); + } + } +}