I got an Android app that requires authentication to be used. As the project grows up, I want to add unit testing in my app.
To do that, I use Espresso 2.1
The thing is:
- My
LoginActivityis called bystartActivityForResult - It shows the form
- a. If the credentials are wrong, it stays on the
LoginActivity - b. If the credentials are ok, it
finishwith aRESULT_OK.
So in my espresso test class, I have some unit tests. Everything is fine with the not ok cases, the problem is on the ok case.
I need to check that the result is RESULT_OK but as the Activity finishes, espresso failed with a
android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
Here is my questions:
- Is there a way to test the
setResultof theActivity? - Is there a workaround (I'd like to not use any of them, but at least...) to be able to test that ?
I've read things about Espresso-Intents but I can't figure out an example on how I can start an activity of my own package and check the result is a RESULT_OK.