Does creating an activity using the .withIntent()
not work in Robolectric 2? I\'m doing the following
activity = Robolectric.buildActivity(
EDIT: It was fixed in version 2.2.
I tackled with the same issue. It was reported but no fix has been provided yet. For now, I manage to hack it using Activity's setter before calling onCreate(), taking advantage from the fact that its lifecycle has not yet started:
Intent intent = new Intent();
MainActivity mainActivity = Robolectric.buildActivity(MainActivity.class)
.create()
.get();
mainActivity.setIntent(intent);
mainActivity.onCreate(null);