Test di debug
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Il modo principale per risolvere i problemi nei test è esaminare l'albero semantico.
Stampa l'albero chiamando il numero composeTestRule.onRoot().printToLog()
in
qualsiasi momento del test. Questa funzione stampa un log come questo:
Node #1 at (...)px
|-Node #2 at (...)px
OnClick = '...'
MergeDescendants = 'true'
|-Node #3 at (...)px
| Text = 'Hi'
|-Node #5 at (83.0, 86.0, 191.0, 135.0)px
Text = 'There'
Questi log contengono informazioni preziose per il rilevamento dei bug.
Risorse aggiuntive
- Testare le app su Android: la pagina di destinazione principale dei test Android offre una visione più ampia delle tecniche e delle nozioni di base dei test.
- Nozioni di base sui test: scopri di più
sui concetti fondamentali alla base del test di un'app per Android.
- Test locali: puoi eseguire alcuni test
localmente, sulla tua workstation.
- Test strumentati: è buona
norma eseguire anche test strumentati. ovvero test eseguiti direttamente
sul dispositivo.
- Integrazione continua:
l'integrazione continua consente di integrare i test nella pipeline di deployment.
- Testa diverse dimensioni dello schermo: con
molti dispositivi a disposizione degli utenti, devi eseguire test per diverse dimensioni
dello schermo.
- Espresso: sebbene sia destinato alle UI basate sulla visualizzazione, la conoscenza di Espresso può comunque essere utile per alcuni aspetti dei test di Compose.
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-09-03 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-03 UTC."],[],[],null,["The main way to solve problems in your tests is to look at the semantics tree.\nPrint the tree by calling `composeTestRule.onRoot().printToLog()` at\nany point in your test. This function prints a log like this: \n\n Node #1 at (...)px\n |-Node #2 at (...)px\n OnClick = '...'\n MergeDescendants = 'true'\n |-Node #3 at (...)px\n | Text = 'Hi'\n |-Node #5 at (83.0, 86.0, 191.0, 135.0)px\n Text = 'There'\n\nThese logs contain valuable information for tracking bugs down.\n\nAdditional Resources\n\n- **[Test apps on Android](/training/testing)**: The main Android testing landing page provides a broader view of testing fundamentals and techniques.\n- **[Fundamentals of testing](/training/testing/fundamentals):** Learn more about the core concepts behind testing an Android app.\n- **[Local tests](/training/testing/local-tests):** You can run some tests locally, on your own workstation.\n- **[Instrumented tests](/training/testing/instrumented-tests):** It is good practice to also run instrumented tests. That is, tests that run directly on-device.\n- **[Continuous integration](/training/testing/continuous-integration):** Continuous integration lets you integrate your tests into your deployment pipeline.\n- **[Test different screen sizes](/training/testing/different-screens):** With some many devices available to users, you should test for different screen sizes.\n- **[Espresso](/training/testing/espresso)**: While intended for View-based UIs, Espresso knowledge can still be helpful for some aspects of Compose testing."]]