After a bit of a hectic few days I managed to get basic gametests running.
I followed the primer and it got more and more clear with every new readthrough.
The primer has an ExampleTestInstance which is the E2ETests file of mine. This is extremely ugly for neo 1.21.5 but it proves the point. A TestInstance (yarn) which is the equivalent of GameTestInstance in mojmap is a "single test". Its start method is the body of the test. Since my E2ETests class is an old test for a different setup, it just now acts as a runner of my old tests but it does the trick - kinda. I don't recommend this in the long run but it's a good step in my refactoring.
Now this TestInstance is actually a type of test in the new 1.21.5 world.
Before you can do anything, you need to register it. I am doing it this way and I'm fairly certain it's not the right place for it.
The DeferredRegister declaration I got from the neoforge codebase so it might be alright. Please tell me how I can make thie better!
Now. Up until this point we have a thing that can run tests and Minecraft now knows about it but this does not mean we have tests per se.
You must create a JSON file (or possibly register a TEST_FUNCTION, idk) that references this test type that we just registered.
Notice how the "type": "serverredstoneblock:srs_test_instance", in my JSON is the RegistryHelper.TEST_INSTANCES.register("srs_test_instance", () -> E2ETests.CODEC); we registered in the registry.
Notice that there has been no mention of the RegisterGameTests event. I found it not work for this but I'm not sure if it was just user error. Please show me a better way!
Also if you're using Architectury, you need to adjust your gameTestServer loom runs to include the environment and forgeTemplate settings.
loom.runs {
create("gameTestServer") {
server()
environment("gametestserver")
forgeTemplate("gametestserver")
}
}Also if you use stonecutter+architectury, I've now updated Stonecraft to deal with this.
PSA: please ignore the messy codebase, SearverRedstoneBlock also doubles as my experimentation testbed with some of these things so it's never in a nice to look at state.