I want to write Robotium test case for my activity. Test case extends stadard ActivityInstrumentationTestCase2 as shown in Robotium samples. Activity represents a data-value object which persisted in locale storage and must take an object id as parameter in intent extras. Later in onCreate data-value object will be obtained from DB by this id.
Therefore, in setUp method i want to create mocked data-value object, persist it into local storage and pass their id into activity via intent extras. But for persisting i need a Context instance. Only one way to do this in ActivityInstrumentationTestCase2 is use getActivity() for this. But this will create an instance of my activity before than mocked object will be persisted.
What can i do in this situation?
Context without calling
getActivitycan be obtained fromgetInstrumentation().getTargetContext()