Mock up account in ActivityInstrumentationTestCase2
问题 In my Activity, I get accounts in onCreate() : public void MyActivity extends Activity{ ... private Account[] accounts; @Override protected void onCreate(){ accounts = AccountManager.get(this).getAccounts(); } ... } Now, I am unit testing MyActivity in test project: public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> { ... @Override protected void setUp() throws Exception{ super.setUp(); //How to mock up the accounts in system so that some fake accounts could be