Shynixn / MCCoroutine

MCCoroutine is a library, which adds extensive support for Kotlin Coroutines for Minecraft Server environments.
Other
211 stars 19 forks source link

Implement Folia Unit-Testing #126

Closed MC-XiaoHei closed 1 month ago

MC-XiaoHei commented 1 month ago

I am going to create an unit-testing in folia, i have these:

    testImplementation("com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.19.0")
    testImplementation("com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.19.0")
    testImplementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-test:2.19.0")

and when i run test, i got this:

Failed to load MCCoroutine implementation. Shade mccoroutine-folia-core into your plugin.
java.lang.RuntimeException: Failed to load MCCoroutine implementation. Shade mccoroutine-folia-core into your plugin.
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt$mcCoroutine$2.invoke(MCCoroutine.kt:23)
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt$mcCoroutine$2.invoke(MCCoroutine.kt:18)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt.getMcCoroutine(MCCoroutine.kt:18)
    at com.github.shynixn.mccoroutine.folia.SuspendingJavaPlugin.onEnable(SuspendingJavaPlugin.kt:36)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:288)
    at org.bukkit.plugin.java.JavaPluginUtils.setEnabled(JavaPluginUtils.java:25)
    at be.seeseemelk.mockbukkit.plugin.PluginManagerMock.enablePlugin(PluginManagerMock.java:563)
    at be.seeseemelk.mockbukkit.MockBukkit.load(MockBukkit.java:189)
    at be.seeseemelk.mockbukkit.MockBukkit.load(MockBukkit.java:167)
    at cn.xor7.xiaohei.feaves.ConstantsKt.initMock(Constants.kt:14)
    at cn.xor7.xiaohei.feaves.data.BotDataManagerTest.init(BotDataManagerTest.kt:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.ClassCastException: class com.github.shynixn.mccoroutine.bukkit.test.impl.TestMCCoroutineImpl cannot be cast to class com.github.shynixn.mccoroutine.folia.MCCoroutine (com.github.shynixn.mccoroutine.bukkit.test.impl.TestMCCoroutineImpl and com.github.shynixn.mccoroutine.folia.MCCoroutine are in unnamed module of loader 'app')
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt$mcCoroutine$2.invoke(MCCoroutine.kt:20)
    ... 14 more

class com.github.shynixn.mccoroutine.bukkit.test.impl.TestMCCoroutineImpl cannot be cast to class com.github.shynixn.mccoroutine.folia.MCCoroutine (com.github.shynixn.mccoroutine.bukkit.test.impl.TestMCCoroutineImpl and com.github.shynixn.mccoroutine.folia.MCCoroutine are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.github.shynixn.mccoroutine.bukkit.test.impl.TestMCCoroutineImpl cannot be cast to class com.github.shynixn.mccoroutine.folia.MCCoroutine (com.github.shynixn.mccoroutine.bukkit.test.impl.TestMCCoroutineImpl and com.github.shynixn.mccoroutine.folia.MCCoroutine are in unnamed module of loader 'app')
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt$mcCoroutine$2.invoke(MCCoroutine.kt:20)
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt$mcCoroutine$2.invoke(MCCoroutine.kt:18)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.github.shynixn.mccoroutine.folia.MCCoroutineKt.getMcCoroutine(MCCoroutine.kt:18)
    at com.github.shynixn.mccoroutine.folia.SuspendingJavaPlugin.onEnable(SuspendingJavaPlugin.kt:36)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:288)
    at org.bukkit.plugin.java.JavaPluginUtils.setEnabled(JavaPluginUtils.java:25)
    at be.seeseemelk.mockbukkit.plugin.PluginManagerMock.enablePlugin(PluginManagerMock.java:563)
    at be.seeseemelk.mockbukkit.MockBukkit.load(MockBukkit.java:189)
    at be.seeseemelk.mockbukkit.MockBukkit.load(MockBukkit.java:167)
    at cn.xor7.xiaohei.feaves.ConstantsKt.initMock(Constants.kt:14)
    at cn.xor7.xiaohei.feaves.data.BotDataManagerTest.init(BotDataManagerTest.kt:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

and in docs i found this:

This site is only relevant for Spigot, Paper and CraftBukkit

does this means that MCCoroutine does not support folia now? if its possible, please support it, thanks

Shynixn commented 1 month ago

(This site is only relevant for Spigot, Paper and CraftBukkit. If you need Unit-Tests support for BungeeCord, Sponge or Velocity, please submit an issue on GitHub)

Well, you need to request com.github.shynixn.mccoroutine:mccoroutine-folia-test:2.19.0 first. It is simply not implemented yet.

MC-XiaoHei commented 1 month ago

yes, i think i need this.

MC-XiaoHei commented 1 month ago

thanks!