Unit testing with Android XmlPullParser on the JVM

I am trying to configure unit test applications for my application.

A critical part of the application parses XML files using org.xmlpull.v1.XmlPullParser. Since this part is low-level, isolated, and independent of actions, context, views, etc., I really wanted it to run locally on the JVM in order to avoid having to connect or emulate the device all the time.

However, when running on the JVM, something like this:

XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
...

I get famous:

Exception in thread "main" java.lang.RuntimeException: Stub!
    at android.util.Xml.newPullParser(Xml.java:15)
    ...

Is there any way around this?

+4
source share
1 answer

, Robolectric Android-Studio. .

, .

+2

All Articles