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 used
}
...
}
In my above test case, I would like to use some fake accounts, how could I mock up the accounts so that AccountManager.get(this).getAccounts();
returns those mocked accounts in my project under test?