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.
Creare un report sui risultati
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive le nozioni di base su come implementare un nuovo report sui risultati e configurarlo per un test.
Interfaccia di base
Per definire un nuovo report sui risultati in Tradefed, una classe deve implementare l'interfaccia ITestInvocationListener
che consente di ricevere e gestire le diverse fasi dell'invocazione:
invocationStarted
invocationEnded
invocationFailed
I report sui risultati gestiscono anche le diverse fasi di ogni esecuzione del test:
testRunStarted
testStarted
testFailed
o testIgnored
testEnded
testRunFailed
testRunEnded
Dati tutti questi eventi, esistono due tipi principali di report sui risultati:
- Concentrati solo sulla generazione di report sui risultati finali completi.
- Intervenire sui risultati parziali.
Report sui risultati che genera risultati finali completi
Questo tipo è il caso più comune quando si interagisce con un servizio esterno che riceve i risultati. Il reporter riceve e accumula semplicemente i risultati, poi li invia tutti su invocationEnded
all'endpoint del risultato.
Consigliamo a questi reporter di estendere CollectingTestListener
anziché
l'interfaccia di base per evitare di implementare nuovamente il salvataggio e la memorizzazione dei risultati fino a invocationEnded
.
Report sui risultati che genera risultati parziali
Questo tipo viene in genere utilizzato per un approccio in streaming dei risultati, quando i risultati vengono ricevuti e inviati immediatamente ad altri luoghi. Ad esempio, un reporter
che registra i risultati nella console è di questo tipo.
Questo tipo è specifico per il tipo di gestione richiesto per gli eventi, pertanto l'implementazione dell'interfaccia di base è in genere la soluzione consigliata.
Configurazione XML
Il tag dell'oggetto è result_reporter
. Ad esempio:
<result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
<option name="suppress-passed-tests" value="true"/>
</result_reporter>
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-27 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-27 UTC."],[],[],null,["# Create a result reporter\n\nThis page describes the basics of how to implement a new result reporter and\nconfigure it for a test.\n\nCore interface\n--------------\n\nIn order to define a new result reporter in Tradefed, a class must implement\nthe\n[`ITestInvocationListener`](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/invocation_interfaces/com/android/tradefed/result/ITestInvocationListener.java)\ninterface that allows receiving and handling different stages of the\ninvocation:\n\n- `invocationStarted`\n- `invocationEnded`\n- `invocationFailed`\n\nResult reporters also handle the different stages of each test run:\n\n- `testRunStarted`\n- `testStarted`\n- `testFailed` or `testIgnored`\n- `testEnded`\n- `testRunFailed`\n- `testRunEnded`\n\nGiven all these events, there are two main types of result reporters, those that:\n\n- Care only about reporting the final complete results.\n- Take action on partial results.\n\n### Result reporter that reports final complete results\n\nThis type is the most common case when it comes to interacting with an external\nservice that receives the results. The reporter simply receives and accumulates\nthe results and then sends them all on `invocationEnded` to the result end-point.\n\nWe recommend that those reporters extend `CollectingTestListener` instead\nof the base interface in order to avoid reimplementing saving and storing the\nresults until `invocationEnded`.\n\n### Result reporter that reports partial results\n\nThis type is usually used for a streaming approach of the results, when results\nare received and pushed to some other places right away. For example, a reporter\nthat logs the results to the console would be of this type.\n\nThis type is specific to which type of handling is required on the events,\nso implementing the base interface is usually the recommended way.\n\n### XML configuration\n\nThe object tag is `result_reporter`. For example: \n\n \u003cresult_reporter class=\"com.android.tradefed.result.ConsoleResultReporter\"\u003e\n \u003coption name=\"suppress-passed-tests\" value=\"true\"/\u003e\n \u003c/result_reporter\u003e"]]