I have a fragment, which when loaded should display a loading spinner which disappears once then the fields are populated when a network request completes. For testing I can mock the request.
In every case it is very fast and You won't usually see the Loading spinner. Is it possible with Espresso to test that this view is shown first? Even when it disappears so quickly?
What are my options to delay the load long enough to make it testable? (Is there some thing in the framework, rather than sleeping the thread?)
This is the result of my test currently:
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is displayed on the screen to the user' doesn't match the selected view.
Expected: is displayed on the screen to the user
Got: "AppCompatImageView{id=2131624534, res-name=loading_spinner, visibility=GONE, width=126, height=126, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=477.0, y=383.0}"