android / android/android-test
Espresso does not wait for androidx.loader.content.ModernAsyncTask
- Lingua principale
- Java
- Stelle
- 1.2k
- Fork
- 342
- Merge medio
- 11h 29m
- PR unite (30g)
- 2
Descrizione
### Description
After migrating to AndroidX, test execution became much less reliable. It appears that Espresso is no longer waiting for androidx.loader.content.AsyncTaskLoader to emit updated data to onLoadFinished() when tests use the content resolver to insert new data. I believe this problem may have at least two causes.
1. androidx.loader.app.LoaderManagerImpl.LoaderViewModel.hasRunningLoaders() only seems to return true up until the first value is emitted by a loader. Subsequent content change notifications aren't considered.
2. androidx.loader.content.ModernAsyncTask doesn't appear to be monitored by Espresso. THREAD_POOL_EXECUTOR from the support library version is [still referenced here](https://github.com/android/android-test/blob/master/espresso/core/java/androidx/test/espresso/base/ThreadPoolExecutorExtractor.java#L42).
### Steps to Reproduce
* Set up content provider and a basic activity that loads an entity with androidx.loader.content.AsyncTaskLoader and shows its content on screen.
* In a test, start an activity with the loader and then insert an entity into the database with the content resolver (also from the test).
* Use Espresso to check that the data has been rendered to a view.
### Expected Results
The data should be shown and Espresso checks should pass.
### Actual Results
Espresso usually passes but in rare instances it fails. Espresso waits for loaders to emit at least one value, even an initial null, but it continues immediately thereafter. This seems to be true even when there are pending content change notifications.
### AndroidX Test and Android OS Versions
androidx.test.espresso: 3.1.1
Android API: 28
### Link to a public git repo demonstrating the problem:
May be able to provide if needed.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con ThreadPoolExecutorExtractor.java ed esamina il THREAD_POOL_EXECUTOR della support-library a cui si fa riferimento, insieme a ModernAsyncTask. Poi segui LoaderManagerImpl.LoaderViewModel.hasRunningLoaders() e riproduci lo scenario di inserimento in content-resolver descritto nell’issue. Il lavoro è completato quando Espresso attende in modo affidabile i dati aggiornati del loader e i controlli corrispondenti superano l’esecuzione senza errori intermittenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- mobile-dev, testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100