Code example for Instrumentation

Methods: getTargetContext

0
    private Instrumentation mInstr;
 
    @Before 
    public void setUp() { 
        mInstr = getInstrumentation();
        mContext = mInstr.getTargetContext();
 
        prepareForResolveActivity(); 
    } 
 
    @Test 
    public void assertPreconditins() { 
        assertNotNull(getInstrumentation());
        assertNotNull(getInstrumentation().getTargetContext());
        assertNotNull(getInstrumentation().getContext());
    } 
 
    private void prepareForResolveActivity() { 
        Intent intent = new Intent(Intent.ACTION_MAIN).setClassName(TEST_PACKAGE_NAME, MainActivity.class.getName());
        RobolectricPackageManager rpm = RobolectricPackageManager.class.cast(mContext.getPackageManager());