I use Espresso to test a lot of activities and transitions between them. I want to write different test for those activities and link the Activity Intents to the corresponding test cases.
1 . Activity A (testActivityA runs)
2. ActivityA launches ActivityB (testActivity B) should be called
is it possible to do this with espresso or any other test framework?
Related
I have some very granular test methods and it would be a total waste of time to start the Activity under test each time. For this it would be very handy to just start it once. Unfortunately Espresso/JUnit finishes all Activities after each test method. Is there a simple way around this?
There is no way to do that. Espresso test cases start activity for test. Espresso is designed like that.
If you want to test specific scenarios you can have separate methods which you can used it in different tests.
For more info :
Why does Espresso leave the app after the test has finished? How to stop it from doing that
Android Espresso testing app flow
I use Espresso to test a lot of activities and transitions between them. I want to write different test for those activities and link the Activity Intents to the corresponding test cases.
1 . Activity A (testActivityA runs) 2. ActivityA launches ActivityB (testActivity B) should be called
is it possible to do this with espresso or any other test framework?
You should test each activity independently of the others. If you need them to react to incoming intents, you can do that using Espresso Intents.
I am new for Junit testing framework. Is it possible to test a flow of activities with assertions to check if each is launched using only exisiting classes provided in android API.
It seems we can only test at activity level. But can we automate a flow : like spawning front and back between activities ?
Yes, through the use of Android instrumentation, which provides you with methods that put you into the drivers seat when interacting with activities as the system would through it's instrumentation framework.
Basically, your able to trigger and manage every aspect of an activities life cycle, including introspecting results from activities calling each other. So if you've worked with the ActivityTestCase that's suitable when testing a single activity, you can have a look at the InstrumentationTestCase that provides you with a low-level approach to work with multiple activities at once.
i have a main activity and when tap on the button in the main activity it moves to the another activity than runs on another process .. is there a chance to track/get that activity using robotium /by means of other codes to integrate with robotium
Unfortunately no. Robotium builds upon Android's instrumentation objects which are limited to work only within the process of the instrumentation for the given target Activity (as you define a target process in the test-manifest file).
I don't know how it behaves in cases where the target process has a defined shared user id, though...
I have one normal android package with an activity A.
Now I am using a second independent test package in which I run several tests.
for testing purposes i want to create an activity B which extends the activity A,
in order to overwrite some aspects of A for testing.
but since activity B is only for testing purposes I want to keep it in the test package.
Is there any possible way for this?