Using Core.createSystemContext()

0
Hello, I am trying to test some of the methods I have written, but in order to do so I need to create a "mock" context in which they can be called. Many use the IContext for retrieveXPathQuery. This is part of the code I have at the moment: ** import junit.framework.TestCase; import com.mendix.core.Core; import com.mendix.systemwideinterfaces.core.IContext; public class MendixTranslationUnitServiceIT extends TestCase { IContext context; (...) private void init() { context = Core.createSystemContext(); } } ** I keep getting a NullPointerException, and what I can find as documentation is: "static IContext com.mendix.core.Core.createSystemContext() [static] Returns the context of the system session (this is always a sudo context). The system session has no associated user or user roles. Returns: returns the system session context. " Can anyone tell me what I'm doing wrong? Thank you!
asked
2 answers
1

It seems like you are creating JUnit testsuites ("import junit.framework.TestCase;"). Are you running from a JUnit test suite runner? That does not work because JUnit cannot start the runtime headless.

We do however use JUnit here as well. We have a module available that can run JUnit or Microflow unit tests from your Mendix app. If interested please file a ticket at support.mendix.com, then I'll try to find some time to publish it in the appstore (please refer to this thread).

UPDATE

Well, since it is the last day of the year after all, took some time to publishit in the appstore right away: https://appstore.mendix.com/link/app/UnitTesting

Happy testing and happy new year everyone :).

answered
0

Is there any chance that you can make the app available for the 3.1.1 version of the modeler? Right now it's 4.1.1 compliant.

answered