I am currently trying to test drive android code with Robolectric. I need to check that the bundle I am sending with an intent in order to create a new activity contains what I expect it to.
Looking around online, I found mention of ShadowFragment in Robolectric 2.0-alpha 1 documents which has getArguments() that seems like it would do what I need, but it doesn't seem to be mentioned at all in the 2.4 documents and I can't get org.robolectric.shadows.ShadowFragment to resolve.
Has it moved, is there a workaround, or is there another direction that I need to go in order to inspect an activity's bundle in Robolectric?
Any help would be greatly appreciated.
I hope I understood your needs correctly.
So I assume you need next code in your test:
public void ActivityFiredCorrectly_WhenSomethingDone() {
// some code that launch activity
Intent nextStartedActivity = ShadowApplication.getInstance().getNextStartedActivity();
// check intent parameters
}
If it is not enough you could inspect shadow of the intent:
ShadowIntent shadowIntent = shadowOf(nextStartedActivity);
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With