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?
Asked
Active
Viewed 104 times
0
-
1"For this it would be very handy to just start it once" -- that would leave lingering state that might affect other tests. A test method needs a consistent starting point, not one that varies based on what other test methods happen to have executed previously. – CommonsWare Aug 11 '17 at 14:55
-
@CommonsWare Of course, but as stated the tests are very granular (and: they don't interfere with each other). It can make sense under certain circumstances and speed up a test significantly. – nepa Aug 12 '17 at 18:14
1 Answers
1
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

Jitesh Mohite
- 31,138
- 12
- 157
- 147