Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to add Extras to Activity using ActivityInstrumentationTestCase2

I'm doing unit testing using the ActivityInstrumentationTestCase2. Is there a way to add extras to the activity so when the activity gets to a line like this

 Bundle extras = getIntent().getExtras();

it will return extras?

like image 277
slim Avatar asked Jan 31 '11 22:01

slim


1 Answers

You can call setActivityIntent in your tests setUp() method before ever calling getActivity, to change the intent that's used to launch the activity under test. This intent will then become the one returned by getIntent() in your activity.

like image 133
superfell Avatar answered Sep 19 '22 02:09

superfell