I have MainActivity and SubActivity.
MainActivity has a button triggering a startActivityForResult calling SubActivity.
The SubActivy has the responsibility to add a record to a certain repository so that when it calls finish, the MainActivty, in the method onActivityResult, has to call the notifyDataSetChanged on the adapter:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_OK && requestCode == 1) {
adapter.notifyDataSetChanged();
}
}
Now, is there a way to test this come and go with Robolectric? Right now I'm able to test the intent called with a click from MainActivity to SubActivity (using Shadow objects), but I can't see no way to trigger the finish on SubActivity (with the new element added to the repository) so I can check that the adapter is showing the new element on MainActivity
I'm new to Roboelectric so I don't if what I want to test is beyond what this framework is about. Should I use Mockito?
I would have two unit tests for both activities.
The MainActivityTest:
SubActivity intent startedonActivityResult refreshes the list on RESULt_OKThe SubActivityTest:
RESULT_OKFor the entire acceptance tests I would use Robotium or Calabash
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