Issue
I have gone through the doc of espresso but still do not get the benefits of it so that I can move to espresso over instrumentation. Can somebody help with that?
What I know from espresso is:
- A key benefit of using Espresso is that it provides automatic synchronization of test actions with the UI of the app you are testing.
- Espresso detects when the main thread is idle, so it is able to run your test commands at the appropriate time, improving the reliability of your tests.
- This capability also relieves you from having to add any timing workarounds, such as
Thread.sleep()
in your test code.
Here at point 1 I am not able to get how it is maintaining synchronization while taking action.
At point 2 how threads become idle and How we can avoid Thread.sleep()
is espresso wait for element until it is not shown on the screen.
Please suggest how I should go with it. Thanks
Solution
but still not getting the benefits of it so that I can move to espresso over instrumentation
I think you are confusing some things here:
Instrumentation-Test
is not neccessary meaning you have to use espresso
.
Generally Instrumented Tests
are tests that:
...can take advantage of the Android framework APIs and supporting APIs, such as the Android Testing Support Library. Source
This means that you can either write "classic" unit tests or instrumented unit tests that for example need an android context to run. Unit tests are tests that test single parts of your code, e.g. services or stuff like that.
UI tests on the other hand are tests that really start up your activity and perform some action in your app.
Espresso itself is just a library to help you write automated UI tests. You can use it to interact with UI within your app (click buttons, check content of views, ...).
Furthermore there is the ui-automator library which can do a similar thing but is intended for UI interactions that are not within your app but for example system dialogs (permission dialog, recent-app or home button, ...) or if you have test cases that span across multiple apps.
So to answer your question: You cannot "favor" espresso over instrumentation tests since espresso is a library used for automated instrumentation tests.
Answered By - stamanuel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.