Before we go down this “rabbit hole” could you please elaborate why you don’t want to use JUnit?
TL;DR: What you are trying to do could work but it is largely untested, so you will probably run into some bugs lurking in the shadow.
The Java classes are only added to the Objective-C runtime at runtime: this means, that they don’t exist as .m or .h before that. The moe-main-interfaces.m file includes
#ifdef guards, so this file is not included in the build -> so the compiler can’t pick its contents up either - but Interface Builder / Storyboards will work with it, so it serves its purpose.
Technically, if you remove these guards manually it should still work, so your compiler could find these classes and you could reference them from your tests, and when Nat/J initializes (see below for that issue), it will merge with the already existing ObjC stubs. That said, we usually support this method the other way around: you create your empty ViewControllers in ObjC, and then use Natjgen to create the bindings in Java, which you extend in Java (so they actually become hybrid classes and not real bindings). Also, our Java -> ObjC stub generator was not intended to create a complete representation of the Java class in ObjC, only the things required for Interface Builder are generated, so some things could be missing that you want to test.
Another issue: I assume that the Xcode tests use a different entry point and not main.m. This means that the
moevm() call is not executed, so the Java runtime will not be initialized when the tests run. One would need to call
moevm() exactly once before running the tests to make sure that the Java runtime is initialized. Also: it would need to be called in a way to make sure that it returns (i.e. the Java main method exits), but the runtime stays initialized, so your
@RegisterOnStartup classes can be found by the Objective-C runtime.
I recall, that we did something like this earlier (it was like in early 2016), but this is not something we test regularly, so I am not sure if it is broken or not.