27 Mart 2025'ten itibaren AOSP'yi derlemek ve AOSP'ye katkıda bulunmak için aosp-main yerine android-latest-release kullanmanızı öneririz. Daha fazla bilgi için AOSP'de yapılan değişiklikler başlıklı makaleyi inceleyin.
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Cihaz tarafında testler (ör. enstrümantasyonlar, kullanıcı arayüzü otomasyon testleri) çalıştırırken, metrik toplamayı cihazda çalışan bir testle senkronize etmek zor olduğundan ana makine tarafında toplayıcılar ideal olmayabilir. Örneğin, eşzamansız olarak alınan bir ekran görüntüsünün istenen ekranı kaçırması ve işe yaramaması olasıdır.
Bu kullanım alanlarını karşılamak için toplayıcılarımızın cihaz tarafında bir sürümü mevcuttur ve herhangi bir AndroidJUnitRunner enstrümanında kullanılabilir.
BaseMetricListener, toplanan metrikleri Tradefed raporlama ardışık düzeniyle tamamen uyumlu bir şekilde otomatik olarak raporlamak için uygulanabilir.
Bu kitaplık, Tradefed'den ayrılmıştır ve Tradefed olmadan kullanılabilir.
Tradefed'den AndroidJUnitTest çalıştırıcısını kullanıyorsanız toplayıcınızı testlerinizle birlikte çalıştırmak için aşağıdaki komut satırı seçeneğini belirtebilirsiniz:
Temel sınıf BaseMetricListener'ün üzerine uygularken, enstrümantasyonun yaşam döngüsü sırasında metriklerinizi ne zaman toplamak istediğinizi seçebilirsiniz:
Test çalışması başladığında: onTestRunStart
Bir test kaydı başladığında: onTestStart
Bir test senaryosu sona erdiğinde: onTestEnd
Bir test durumu başarısız olduğunda: onTestFail
Test çalışması sona erdiğinde: onTestRunEnd
Etkileşim
Cihaz tarafında metrik toplama işlemi, enstrümantasyon yürütme işlemiyle senkronize bir şekilde yapılır. Metrikler, enstrümantasyon sonuçlarına geri aktarılır ve çağrının bir parçası olarak raporlanmaları için Tradefed tarafından ayrıştırılır.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-27 UTC."],[],[],null,["# Device-side metrics collectors\n\nWhen running device-side tests (for example, instrumentations, UI Automator\ntests), host-side collectors might not be ideal because it's difficult to\nsynchronize metric collection to a test running on a device. For example, a\nscreenshot taken asynchronously is likely to miss the wanted screen and be\nuseless.\n\nTo meet these use cases, a device-side version of our collectors exists\nand can be used in any `AndroidJUnitRunner` instrumentation.\n[`BaseMetricListener`](https://android.googlesource.com/platform/platform_testing/+/refs/heads/android16-release/libraries/device-collectors/src/main/java/android/device/collectors/BaseMetricListener.java)\ncan be implemented to automatically report metrics that are collected\nin a way fully compatible with the Tradefed reporting pipeline.\n\nThis library is decoupled from Tradefed itself and can be used without Tradefed.\n\nIf you're using the [`AndroidJUnitTest`](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/test_framework/com/android/tradefed/testtype/AndroidJUnitTest.java)\nrunner from Tradefed, you can specify the following command line option\nto have your collector running with your tests: \n\n --device-listeners android.device.collectors.ScreenshotListener\n\n**Caution:** In order for the collector classes to be resolved at runtime, your instrumentation APK needs to statically include them by adding the following to your makefile: \n\n LOCAL_STATIC_JAVA_LIBRARIES += collector-device-lib\n\nImplementation\n--------------\n\nWhen implementing on top of the base class `BaseMetricListener`, you can choose\nwhen you would like to collect your metrics during the lifecycle of the\ninstrumentation:\n\n- When a test run starts: `onTestRunStart`\n- When a test case starts: `onTestStart`\n- When a test case ends: `onTestEnd`\n- When a test case fails: `onTestFail`\n- When a test run ends: `onTestRunEnd`\n\nInteraction\n-----------\n\nThe collection of metrics on the device side is made synchronously to the\ninstrumentation execution itself, and metrics are passed back to the\ninstrumentation results and parsed by Tradefed to be reported as part of the\ninvocation."]]