A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release
anziché aosp-main
per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Esegui test automatici (Android 11 o versioni successive)
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Esistono due opzioni per eseguire i test automatici CTS:
Trade Federation è un framework per app e test che ti consente di eseguire test dalla riga di comando. Fondamentalmente, il framework consente di annotare i test utilizzando l'annotazione @Test
e l'app li trova ed esegue.
OmniLab Android Test Station è un'app che ti consente di eseguire test
in una GUI.
Questa pagina spiega come eseguire test automatici utilizzando Trade Federation. Per istruzioni su come eseguire test utilizzando OmniLab Android Test Harness, consulta la sezione OmniLab Android Test Station.
Esegui tutti i test CTS automatici
Trade Federation contiene la console CTS, un'interfaccia a riga di comando per eseguire i test. Per eseguire l'intera suite di test CTS automatica:
- Assicurati di aver seguito le istruzioni riportate in Configurare i test automatici CTS.
Nella workstation di test, avvia la console CTS eseguendo lo script cts-tradefed
dalla cartella in cui è stato decompresso il pacchetto CTS:
./android-cts/tools/cts-tradefed
La console CTS mostra un cursore per consentirti di digitare i comandi CTS
(cts-tradefed >
).
Il piano di test cts
contiene tutti i test CTS automatici. Esegui questo comando per eseguire il piano di test cts
:
run cts
Vengono eseguiti i test CTS automatici. Nota:
Android 13 e versioni successive supportano i test su più dispositivi. Questi test vengono eseguiti automaticamente solo quando viene utilizzato lo sharding. Per ulteriori informazioni sullo sharding, consulta Migliorare il tempo di esecuzione del test. Se vuoi eseguire questi test manualmente, consulta Eseguire test multidispositivo.
Ogni volta che esegui CTS, premi Ctrl+C per arrestare la console CTS esistente e poi esegui di nuovo la console CTS.
Non puoi eseguire più versioni di CTS su un singolo host perché ciascuna si apre con un server di codice posizione aperto (OLC) esistente.
Visualizza i risultati del test. Per saperne di più, consulta Interpreta i risultati del CTS.
Se è la prima volta che esegui il test, alcuni test potrebbero non andare a buon fine a causa di problemi non risolvibili. Ad esempio, la connessione di rete potrebbe essere lenta o il segnale GPS potrebbe essere debole. Esegui di nuovo (riprova) i test finché non sono stati completati tutti i moduli di test e i numeri di errori di test sono gli stessi tra le ultime due sessioni di ripetizione:
run retry --retry session_number`
Una volta che gli errori dei test sono coerenti tra i vari tentativi, concentrati sul debug
degli altri test non riusciti. Per informazioni sulla risoluzione dei problemi relativi ai risultati dei test, consulta Eseguire la triage degli errori di test e Risolvere i problemi relativi ai test CTS.
Esegui CTS per i dispositivi multischermo
Se il tuo dispositivo è in esecuzione su Android 11 o 12 e ha più schermate, devi eseguire il piano di test cts-foldable
separatamente:
run cts-foldable
I casi di test superati o non superati per la modalità schermo alternativa vengono aggiunti con il valore di display_mode
, ad esempio testcase1[display_mode=0]
.
Eseguire test multidispositivo (Android 15 o versioni precedenti)
Esegui il comando seguente per eseguire il piano di test cts-multidevice
:
run cts-multidevice
Eseguire singoli piani di test
Anziché eseguire tutti i piani di test contemporaneamente, puoi eseguire singoli piani di test.
Questa opzione è utile per risparmiare tempo e concentrarsi su un insieme specifico di test.
Per eseguire un singolo piano di test:
Identifica il nome del piano di test che vuoi eseguire eseguendo il comando list modules
.
Esegui il piano di test:
run cts --plan test_module_or_plan_name
Migliorare il tempo di esecuzione del test
Se vuoi migliorare il tempo di esecuzione dei test, puoi suddividerli su più dispositivi. Lo sharding richiede che l'host colleghi almeno due dispositivi, ma per motivi di efficienza sono consigliati almeno sei dispositivi.
Per eseguire il suddivisione dei test su Android 11 o versioni successive, esegui:
run cts --shard-count number_of_shards
Inoltre, prima di eseguire i test per la convalida, puoi migliorare il tempo di esecuzione dei test utilizzando il comando CTS run cts-dev
. Questo comando salta
le pre condizioni, la raccolta delle informazioni del dispositivo e tutti i controlli dello stato del sistema.
Inoltre, esegue i test su un'unica ABI.
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-07-30 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-07-30 UTC."],[],[],null,["# Run automated tests (Android 11 or higher)\n\nThere are two options for running CTS automated tests:\n\n- *Trade Federation* is an app and test framework that lets you\n run tests from the command line. Fundamentally, the framework\n lets you annotate tests using the `@Test` annotation and the app finds and runs\n those tests.\n\n- *OmniLab Android Test Station* is an app that lets you run tests\n in a GUI.\n\nThis page explains how to run automated tests using Trade Federation. For\ninstructions on running tests using OmniLab Android Test Harness, see\n[OmniLab Android Test Station](/docs/core/tests/development/android-test-station/ats-user-guide).\n\nRun all automated CTS tests\n---------------------------\n\nTrade Federation contains the *CTS console*, a command-line interface for\nrunning tests. To run the entire automated CTS test suite:\n\n1. Ensure you have followed the instructions in [Set up CTS automated testing](/docs/compatibility/cts/setup).\n2. On your test workstation, launch the CTS console by running the `cts-tradefed` script from the folder where the CTS package has been unzipped:\n\n ./android-cts/tools/cts-tradefed\n\n The CTS console displays a cursor for you to type CTS commands\n (`cts-tradefed \u003e`).\n3. The `cts` test plan contains all of the automated CTS tests. Execute the\n following command to run the `cts` test plan:\n\n run cts\n\n The automated CTS tests execute. Note the following:\n - Android 13 and higher support multidevice testing. These tests run\n automatically only when sharding is used. For further information on sharding,\n see [Improve test execution time](#improve). If you want to run these tests\n manually, see [Run multidevice tests](#multi-device-testing).\n\n - Whenever running CTS, press **ctrl+c** to stop the existing CTS console\n and then rerun the CTS console.\n\n - You can't run multiple CTS versions on single host because each opens\n with an existing open location code (OLC) server.\n\n4. View test results. For more information, see [Interpret CTS results](/docs/compatibility/cts/interpret).\n\n5. If this is your first test run, there might be tests that fail due to issues beyond your control. For example, a network connection might be slow or a GPS signal might be weak. Rerun (retry) the tests until all test modules are completed and the test failure numbers are the same between the last two retry sessions:\n\n run retry --retry \u003cvar translate=\"no\"\u003esession_number\u003c/var\u003e`\n\n | **Note:** For implementation details for CTS retry, see [Use suite retry](/docs/core/tests/tradefed/testing/through-suite/suite-retry).\n | **Note:** For instructions on how to run a retry session on Android 10 or lower, see [Run CTS automated tests (AOSP 10 or lower)](/docs/compatibility/cts/run-older).\n6. After tests failures are consistent across retries, focus on debugging\n the remaining failed tests. For information on troubleshooting test\n results, see\n [Triage test failures](/docs/compatibility/cts/interpret#triaging-test-failures)\n and\n [Troubleshoot CTS tests](/docs/compatibility/cts/troubleshooting).\n\n| **Note:** For a list of all CTS console commands, see [CTS v2 command console](/compatibility/cts/command-console-v2).\n\nRun CTS for multiscreen devices\n-------------------------------\n\nIf your device is running Android 11 or 12, and your device has multiple\nscreens, you must run the `cts-foldable` test plan separately: \n\n run cts-foldable\n\nPassed or failed test cases for alternate screen mode are appended with the\nvalue from `display_mode`, for example, `testcase1[display_mode=0]`.\n| **Note:** For instructions on how to run the `cts-foldable` test plan for Android 10 or lower, see [Run CTS automated tests (Android 10 or lower)](/docs/compatibility/cts/run-older).\n\nRun multidevice tests (Android 15 or lower)\n-------------------------------------------\n\nExecute the following command to run the `cts-multidevice` test plan: \n\n run cts-multidevice\n\nRun individual test plans\n-------------------------\n\nInstead of running all test plans at once, you can run individual test plans.\nThis option is useful to save time and to focus on a specific set of tests.\nTo run an individual test plan:\n\n1. Identify the name of the test plan you want to run by executing the `list modules` command.\n\n | **Note:** For instructions on how to identify the module on Android 10 or lower, see [Run CTS automated tests (Android 10 or lower)](/docs/compatibility/cts/run-older).\n2. Run the test plan:\n\n run cts --plan \u003cvar translate=\"no\"\u003etest_module_or_plan_name\u003c/var\u003e\n\nImprove test execution time\n---------------------------\n\nIf you want to improve test execution time, you can shard tests across multiple\ndevices. Sharding requires the host to connect at least two devices, but six or\nmore devices are recommended for efficiency.\n\nTo shard tests on Android 11 or higher, run: \n\n run cts --shard-count \u003cvar translate=\"no\"\u003enumber_of_shards\u003c/var\u003e\n\nAdditionally, before running your tests for validation you can improve test\nexecution time by using the CTS `run cts-dev` command. This command skips\npreconditions, device-information collection, and all system status checkers.\nIt also runs the tests on only a single ABI."]]