Come dice il titolo, fallisce un po 'di volte, altri il successo.A volte lo Snackbar e l'Espresso falliscono
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: "AppCompatTextView{id=2131492981, res-name=snackbar_text, visibility=VISIBLE, width=444, height=71, 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=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=18.0, y=0.0, text=Network Error, input-type=0, ime-target=false, has-links=false}"
La prima riga di traccia stack indica che l'espresso non è in grado di vedere lo Snackbar sullo schermo. Ma la seconda riga afferma che in realtà sta vedendo uno Snackbar con visibility=VISIBLE
e text=Network Error
che è corretto.
Sono confuso, cosa sta succedendo?
Questo è il mio codice di prova:
activityRule.launchActivity(new Intent());
onView(withText("Network Error")).check(matches(isDisplayed()));
PS: non riesce per lo più quando si esegue l'intera prova costume; ma a volte fallisce anche quando eseguo questo test da solo. Altre volte passa in verde, ma non c'è alcun modello, sembra casuale.
GRAZIE! Sono così felice che ci sia una soluzione a questo che non richiede rinunciare ai test dell'interfaccia utente. – AdamMc331
In realtà ho appena provato anche questo, e ho avuto lo stesso problema. :( – AdamMc331