mirror of
https://github.com/RoBaertschi/EnvironmentTech.git
synced 2025-04-19 23:03:28 +00:00
Get unittests to work
This commit is contained in:
parent
f3da2f5271
commit
5373cfc84f
@ -34,6 +34,7 @@ base {
|
|||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
// Include resources generated by data generators.
|
// Include resources generated by data generators.
|
||||||
main.configure {
|
main.configure {
|
||||||
@ -42,10 +43,30 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
create("junit") {
|
create("junit") {
|
||||||
|
java {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileClasspath += sourceSets.main.get().output
|
||||||
|
runtimeClasspath += sourceSets.main.get().output
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val junitImplementation: Configuration by configurations.getting {
|
||||||
|
extendsFrom(configurations.implementation.get())
|
||||||
|
}
|
||||||
|
val junitRuntimeOnly: Configuration by configurations.getting {
|
||||||
|
extendsFrom(configurations.runtimeOnly.get())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
configurations["junitImplementation"].extendsFrom(configurations.implementation.get())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//minecraft.accessTransformers.file rootProject.file("src/main/resources/META-INF/accesstransformer.cfg")
|
//minecraft.accessTransformers.file rootProject.file("src/main/resources/META-INF/accesstransformer.cfg")
|
||||||
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
|
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
|
||||||
@ -73,6 +94,7 @@ runs {
|
|||||||
|
|
||||||
create("junit") {
|
create("junit") {
|
||||||
junit(true)
|
junit(true)
|
||||||
|
|
||||||
unitTestSources(sourceSets["junit"])
|
unitTestSources(sourceSets["junit"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,12 +125,12 @@ runs {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations["junitImplementation"].extendsFrom(configurations.implementation.get())
|
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
runs["junit"].modSources = runs["junit"].modSources.get().stream().filter { it != sourceSets.main }.toList()
|
runs["junit"].modSources = runs["junit"].modSources.get().stream().filter { it != sourceSets.main.get() }.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Specify the version of Minecraft to use.
|
// Specify the version of Minecraft to use.
|
||||||
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
|
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
|
||||||
@ -121,16 +143,12 @@ dependencies {
|
|||||||
|
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
|
junitImplementation(platform("org.junit:junit-bom:5.10.2"))
|
||||||
|
junitImplementation("org.junit.jupiter:junit-jupiter-params")
|
||||||
|
junitRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||||
|
|
||||||
sourceSets.getByName("junit") {
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
implementation(platform("org.junit:junit-bom:5.10.2"))
|
junitImplementation("org.assertj:assertj-core:3.25.1")
|
||||||
implementation("org.junit.jupiter:junit-jupiter-params")
|
|
||||||
runtimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// "junitImplementation"(platform("org.junit:junit-bom:5.10.2"))
|
// "junitImplementation"(platform("org.junit:junit-bom:5.10.2"))
|
||||||
// "junitImplementation"("org.junit.jupiter:junit-jupiter-params")
|
// "junitImplementation"("org.junit.jupiter:junit-jupiter-params")
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package robaertschi.environmenttech.unittest;
|
||||||
|
|
||||||
|
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod(value = TestMod.MOD_ID)
|
||||||
|
public class TestMod {
|
||||||
|
public static final String MOD_ID = "environmenttech_tests";
|
||||||
|
}
|
@ -1,7 +1,21 @@
|
|||||||
package robaertschi.environmenttech.unittest;
|
package robaertschi.environmenttech.unittest;
|
||||||
|
|
||||||
import net.neoforged.testframework.annotation.TestGroup;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import robaertschi.environmenttech.client.screen.ProgressArrowComponent;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
public class TestProgressBar {
|
public class TestProgressBar {
|
||||||
|
int gsp(int progress, int maxProgress) {
|
||||||
|
return ProgressArrowComponent.getScaledProgress(progress, maxProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testScales() {
|
||||||
|
int scale1 = ProgressArrowComponent.getScaledProgress(1, 24);
|
||||||
|
assertThat(scale1).isEqualTo(1);
|
||||||
|
assertThat(gsp(24, 24)).isEqualTo(24);
|
||||||
|
assertThat(gsp(1, 12)).isEqualTo(2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
5
src/junit/resources/META-INF/neoforge.mods.toml
Normal file
5
src/junit/resources/META-INF/neoforge.mods.toml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
modLoader="javafml"
|
||||||
|
loaderVersion="[2,)"
|
||||||
|
license="MIT"
|
||||||
|
[[mods]]
|
||||||
|
modId="environmenttech_tests"
|
Loading…
x
Reference in New Issue
Block a user