android / android/android-test
IntentsTestRule does not capture immediate intents
- Vorherrschende Sprache
- Java
- Sterne
- 1.2k
- Forks
- 342
- Ø Merge
- 11 Std. 29 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
### Description
When using IntentTestRule, Intents that get started immediately (for example from `onCreate` method of the tested activity) do not get matched.
### Steps to Reproduce
1. Create an activity that starts another activity in its `onCreate` method
2. Create test for that activity using `IntentsTestRule` that attempts to match start intent
3. Test will fail -
### Expected Results
Start of another activity should be recorded
### Actual Results
Intents will not detect any intents (error message will print out `Recorded intents:[]`)
### AndroidX Test and Android OS Versions
`espresso-intents` 3.1.1
`Android` 9
### Workaround
Workaround to the issue is simple: Create a copy of `IntentsTestRule` and initialize intents in `beforeActivityLaunched` instead of in `afterActivityLaunched`
Beitragsleitfaden
Rechercherichtung
Lies zunächst IntentsTestRule und vergleiche, wann Intents in beforeActivityLaunched gegenüber afterActivityLaunched initialisiert werden. Reproduziere eine Activity, die aus onCreate eine weitere Activity startet, mit espresso-intents 3.1.1, und überprüfe anschließend, dass der Start aufgezeichnet wird, anstatt Recorded intents:[] zu erzeugen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, java
- Bereich
- mobile, testing
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100