I am using ActivityInstrumentationTestCase2 for the unit testing of my application. I have a case where user clicks on a button of Activity 'A' and which in turns open a new Activity 'B' where user will do some work and finally some data is returned to Activity 'A' via setResult(RESULT_OK, intent);
Now, i want to test this via jUnit and want to Mock this workflow so that no user interaction is required. Can someone help me with this.
PS: i dont want to use Robotium for this..i just want to do it via plain ActivityInstrumentationTestCase2 and some Mocking framework.
Try this code to
// Check the intent which was started
Intent triggeredIntent = getStartedActivityIntent();
assertNotNull("Intent was null", triggeredIntent);
String data = triggeredIntent.getExtras().getString("URL");
//And
@Override
protected void setUp() throws Exception {
super.setUp();
Intent intent = new Intent(getInstrumentation().getTargetContext(),
MainActivity.class);
startActivity(intent, null, null);
activity = getActivity();
}
For details :: Follow this link
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