You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently wanted to add unit tests to my mod.
In the project, loom is configured with splitEnvironmentSourceSets().
When trying to run the gradle 'test' task, I get the following error:
Minecraft game provider couldn't locate the game! The game may be absent from the class path, lacks some expected files, suffers from jar corruption or is of an unsupported variety/version.
The issue is, that the game common and environment jars are not in the class path.
I fixed the issue by manually adding this to my buildscript:
configurations {
// common
testCompileClasspath.extendsFrom(minecraftCommonNamedCompile)
testRuntimeClasspath.extendsFrom(minecraftCommonNamedRuntime)
// client only
testCompileClasspath.extendsFrom(minecraftClientOnlyNamedCompile)
testRuntimeClasspath.extendsFrom(minecraftClientOnlyNamedRuntime)
}
Now, game provider works, but this error occurs instead:
...
Caused by: java.lang.IllegalArgumentException: The specified resource 'fabric-networking-api-v1.client.mixins.json' was invalid or could not be read
at org.spongepowered.asm.mixin.transformer.MixinConfig.create(MixinConfig.java:1290)
at org.spongepowered.asm.mixin.transformer.Config.create(Config.java:148)
... 41 more
The client mixin files cannot be found (the actual file is different sometimes).
I fixed this by adding this to my build.gradle:
However, the error with the mixins does not occur.
Issue
This manual classpath configuration is a little confusing for mod developers who want to test their code with unit tests, especially when they don't know Gradle well...
Maybe loom could automatically do this configuration for projects with splitEnvironmentSourceSets() or serverOnlyMinecraftJar()?
I am pretty sure that clientOnlyMinecraftJar() needs extra configuration too.
At the very least, I think this should be documented somewhere.
Cheers
The text was updated successfully, but these errors were encountered:
* Setup the test sourceset better when using split sources.
Fixes#1060
Also added a tool to extract test projects to make them easier to work on.
* Fix
Context
I recently wanted to add unit tests to my mod.
In the project, loom is configured with
splitEnvironmentSourceSets()
.When trying to run the gradle 'test' task, I get the following error:
The issue is, that the game common and environment jars are not in the class path.
I fixed the issue by manually adding this to my buildscript:
Now, game provider works, but this error occurs instead:
The client mixin files cannot be found (the actual file is different sometimes).
I fixed this by adding this to my
build.gradle
:Then, everything is working as expected for my client+server project.
For server-only projects
One of my other mods is configured with
serverOnlyMinecraftJar()
.When executing the unit tests, the same game provider error occurs.
I fixed it with:
However, the error with the mixins does not occur.
Issue
This manual classpath configuration is a little confusing for mod developers who want to test their code with unit tests, especially when they don't know Gradle well...
Maybe loom could automatically do this configuration for projects with
splitEnvironmentSourceSets()
orserverOnlyMinecraftJar()
?I am pretty sure that
clientOnlyMinecraftJar()
needs extra configuration too.At the very least, I think this should be documented somewhere.
Cheers
The text was updated successfully, but these errors were encountered: