I am trying to test an app using Robolectric (1.2) and Dagger.
My testing module is very simple:
@RunWith(RobolectricTestRunner.class)
public class XmlTests {
// Injected
@Inject XmlPullParser mParser;
@Inject AlarmActionSpawner mActionSpawner;
@Inject FileHelper mFileHelper;
@Inject XmlSerializer mSerializer;
@Inject ConcurrentObjectMonitor mObjMonitor;
@Module(
includes = ServicesModule.class,
entryPoints = XmlTests.class,
overrides = true
)
static class TestModule {
public TestModule() { }
}
@Before
public void setUp() throws Exception {
Log.i("setUp() entering.");
ObjectGraph og = ObjectGraph.create(new TestModule());
og.validate();
og.inject(this);
...
The included ServiceModule includes XmlServiceModule:
@Module
public class XmlServiceModule {
@Provides @Singleton XmlSerializer provideXmlSerializer() {
return android.util.Xml.newSerializer();
}
@Provides @Singleton XmlPullParser provideXmlPullParser() {
XmlPullParser pullParser = null;
try {
XmlPullParserFactory xppf = XmlPullParserFactory.newInstance();
pullParser = xppf.newPullParser();
} catch (XmlPullParserException e) {
throw new RuntimeException(e.getMessage());
}
return pullParser;
}
Everything is fine, I can debug within eclipse, until XmlPullParserFactory.newInstance() is hit. At that point, I receive the dreaded:
java.lang.RuntimeException: Stub!
at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:13)
at ....
at ....
I am relatively new to Robolectric and Dagger, maybe I am doing something wrong in the implementation, I don't think in the configuration. What should I check to be sure that everything is fine? Do you guys see any obvious mistake in this code?