Issue
I encountered a problem while doing some Espresso UI testing: I want to disable the animations inside my application so that i don't need to set timeouts/need to wait for the animation to finish.
Disabling the Window animation scale, Transition animation scale, Animator duration scale inside the developers options on my android device does not disable the animations while navigating between fragments with the navigation component of android.
The animation is being set like following:
<action
android:id="@+id/confirmationAction"
app:destination="@id/confirmationFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
How can I disable this animation while running my espresso UI tests?
UPDATE:
I followed this guide of google about navigation between fragments with the navigation component.
Then I looked at the guide of google about testing my application with Espresso and on both the first guide and the second guide that i found is that the first point is to disable the animations via developers options, therefore I thought that this was the correct way of disabling the animations
Solution
After some more research, I've found that Espresso is automatically waiting for all animations on the UI Thread to be finished before executing the assertions.
Normally you don't have anything to do if you use normal animations..
If you have to wait for a service call to return value inside your Espresso test you can write some code that will (kotlin) extend ViewInteraction class. inside your extension class you can execute the check method and catch any errors. If there is an error, you can give a small timeout (20ms) and try execute it again with a while loop. When after 2-3 seconds you still have an exception, you can then just throw that exception
Answered By - JavascriptDeveloper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.