Giter Site home page Giter Site logo

alcatrazescapee / mcjunitlib Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 1.0 297 KB

A library that makes it possible to use JUnit tests with Minecraft Forge mods without fear of class loading order.

License: MIT License

Java 100.00%
junit junit5 minecraft minecraft-forge testing-tools

mcjunitlib's People

Contributors

alcatrazescapee avatar cech12 avatar robotgryphon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

compactmods

mcjunitlib's Issues

Which version of 1.16.5?

Hello Again.

So I decided to drop to version of 1.16.5 to be able to use the 1.16 of the library but I'm having issues when running the build.gradle
I downloaded version 1.16.5-36.2.27 of the MDK and the error I get:

"Apply build file "build.gradle" to root project 'forge-1.16.5-36.2.27-mdk" shows a RED circle

The line that seems to be causing it is the testImplementation fg.deobf here:

dependencies {
    classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
	testImplementation fg.deobf('com.github.alcatrazEscapee:mcjunitlib:1.16.5_1.4.4')
}

Any suggestions? Also should I be using a specific MDK?

Thanks so much.

Issue on startup the test server

Hey,
I tried to setup your nice test lib in my environment. I followed the steps of the readme and add 2 tests for testing your lib.
Everytime I start the test server, I get this log:

[20:34:48] [main/UNITTEST] [co.al.mc.DedicatedTestServerLauncher/]: TestServerLauncher Starting
[20:34:48] [main/UNITTEST] [co.al.mc.DedicatedTestServerLauncher/]: Launching Launcher with arguments: --crashOnFailedTests, --gameDir, ., --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.forgeVersion, 36.0.4, --launchTarget, fmltestserver
[20:34:50] [main/UNITTEST] [co.al.mc.TestMain/]: TestMain launching
[20:34:59] [main/UNITTEST] [co.al.mc.TestMain/]: Removing previous test world...
[20:35:06] [main/UNITTEST] [co.al.mc.TestMain/]: Setting random seed: 6762956184618966637
[20:35:06] [Server thread/UNITTEST] [co.al.mc.DedicatedTestServer/]: Server Thread Starting
[20:35:13] [Server thread/UNITTEST] [UnitTests/]: Did not discover any tests to run.
[20:35:13] [Server thread/UNITTEST] [co.al.mc.DedicatedTestServer/]: Encountered an unexpected exception
java.lang.BootstrapMethodError: java.lang.IllegalAccessError: tried to access method net.minecraft.server.MinecraftServer.isAheadOfTime()Z from class com.alcatrazescapee.mcjunitlib.DedicatedTestServer
	at com.alcatrazescapee.mcjunitlib.DedicatedTestServer.func_240802_v_(DedicatedTestServer.java:148) ~[?:1.4.1-1.16.5] {re:classloading}
	at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162] {}
Caused by: java.lang.IllegalAccessError: tried to access method net.minecraft.server.MinecraftServer.isAheadOfTime()Z from class com.alcatrazescapee.mcjunitlib.DedicatedTestServer
	at java.lang.invoke.MethodHandleNatives.resolve(Native Method) ~[?:1.8.0_162] {}
	at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975) ~[?:1.8.0_162] {}
	at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000) ~[?:1.8.0_162] {}
	at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1394) ~[?:1.8.0_162] {}
	at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1750) ~[?:1.8.0_162] {}
	at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477) ~[?:1.8.0_162] {}
	... 3 more
> 
Process finished with exit code 1

It looks like, that there is an issue in accessing the private method MinecraftServer#isAheadOfTime.

I updated my mod to the same Forge version as your lib uses (1.16.5-36.0.4) and I tried the lib versions 1.4.1 and 1.4.3.
What am I doing wrong?

Here is my test branch: https://github.com/cech12/CeramicBucket/tree/feature/automated-tests
and the related commit: cech12/CeramicBucket@e3f16b3

Thanks for your help! :)

Trying to get library to run with MC 1.18

I'm trying to get the library to run using MC 1.18 Is it even possible? Also, which 'run' do I execute because doing a Run with runServerTest returns the following:

[19:12:20] [main/UNITTEST]: TestServerLauncher Starting
[19:12:20] [main/UNITTEST]: Forge is calling, they want their ArgumentList back. This is a bug!
[19:12:20] [main/UNITTEST]: Error:
java.lang.ClassNotFoundException: net.minecraftforge.userdev.ArgumentList
at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[?:?]
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:375) ~[?:?]
at com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher.main(DedicatedTestServerLauncher.java:34) [mcjunitlib-1.4.4-1.16.5_mapped_official_1.18.1.jar:1.4.4-1.16.5]

using runClient starts MC no problem but nothing is displayed from mcJunitLib. Any help would be greatly appreciated.

Plan for 1.17

Hey!

I love this testing library! I started to port my mods to 1.17 and I miss the test aspects^^
So here is my question: Are there any plans of porting this library to support 1.17?
Maybe I could support you doing this.

Greetings
Chris

Support Parameterized Tests

Only junit-jupiter-api and junit-jupiter-engine are currently bundled. JUnit5 also has the junit-jupiter-params package that is required for parameterized tests.

No tests found?

I've been trying to update some previous tests on https://github.com/CompactMods/CompactCrafting and no matter which version I try, it appears the JUnit discoverer is stopping or not discovering any of my test classes.

The classpath directories appear correct, and it looks like the prerequisite builds and combinations of my API lib and main code are all there.. so I'm lost.

Things I've attempted, with no luck:

  • Tried the original version, 1.3.3 in the file
  • Tried to update to 1.4.1
  • Tried to update to 1.4.3
  • Tried regenerating the run configs and running in debug (several times)
  • Tried adding and removing the targetModId environment line
  • Tried adding sourceSets.test (and main/api) under mods { compactcrafting { } }
  • Tried several variations of the README unit tests config
  • Tried removing the destinationDir from the JAR tasks

How do I get runServerTest working?

I created the ExampleTest.java
and its in the src/test/java folder.
When I RUNAS Junit Test, the run fails with Java.lan.ExceptionInitilaizerError.

I don't see (or know how) to get runServerTest working.

When I RUNCONFIGURATIONS runClient it starts MC no problem but I don't see anything
The Console does not display anything about [Server thread/UNITTEST]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.