-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fabric-loader-junit to allow unit testing of transformed classes. #767
Conversation
minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/McLibrary.java
Outdated
Show resolved
Hide resolved
This should now be ready, Gradle 8 has now been released so im happy to merge this pending no other requested changes 👍 |
Going to merge this, I think for now its fair to call this "experimental" as its using a lot of new Junit and Gradle tech with limitations. As this is an advanced dev only feature I am less worried about having to maintain this far into the future if Junit or anything else changes in the future. |
This is great timing! I was just updating a mod that I wrote against 1.17 and started getting this error in my JUnit tests:
It turns out that Adding
I'm hoping that someone more familiar with the internals will have a clearer idea than I do of what the cause may be. My PR with the updates to go from 1.17 to 1.19 is at appropriate/durability-alert-mod#2, but it doesn't seem like the changes I'm making there are causing this since the tests work for the 1.17 version of the mod. |
It seems like perhaps |
Hi, @md5 I think this might be caused by having fabric-loader on the classpath twice. Due to a change made to skip remapping loader its quite easy for a dep to pull in an older version of loader and remap it. I see you have alteast 2 mods that you depend on, a workaround for now is to exclude the fabric-loader transitive dep from them. |
Thanks @modmuss50! appropriate/durability-alert-mod@47178fa fixed things up |
PR to support testing mods with JUnit.
This PR publishes a new
fabric-loader-junit
maven artifact. This can be setup like so:Eclipse / Visual Studio code are not currently supported, users of those IDEs must run the tests via Gradle. Gradle 8 MUST also be used to support this, hence why this PR updates loader to use Gradle 8.0-rc2.
Previous discussion: FabricMC/fabric-loom#742
Doucmentation: https://junit.org/junit5/docs/snapshot/user-guide/#launcher-api-launcher-interceptors-custom
Junit PR adding this: junit-team/junit5#3091