I'm running a junit test in Android which extends ActivityInstrumentationTestCase2. I'm using this on order to start up an activity.
The activity uses a subclass of the application object to obtain some parameters. I get the application object from the context.
Unfortunately, ActivityInstrumentationTestCase2 does not provide access to the context. Is there a way to access the context before getting the activity?
You can get the application context from the instrumentation object:
getInstrumentation().getTargetContext().getApplicationContext()
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