Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release
, bukan aosp-main
, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Menggunakan pengontrol modul
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Setiap modul suite (ditentukan oleh AndroidTest.xml
) dapat berisi objek
module_controller
khusus yang dapat mengubah beberapa perilaku modul:
Apakah akan menjalankan modul atau tidak berdasarkan beberapa kondisi
Dengan menerapkan BaseModuleController
dan menambahkannya ke AndroidTest.xml
seperti ini:
<object type="module_controller" class="com.android.tradefed.testtype.suite.module.<NAME>" />
Pengontrol modul akan digunakan untuk menentukan apakah modul harus dijalankan
atau tidak, berdasarkan
implementasi
public abstract RunStrategy shouldRun(IInvocationContext context);
.
Apakah akan mengumpulkan beberapa log atau tidak saat terjadi kegagalan
Saat menjalankan suite lengkap, Anda dapat meminta pengumpulan beberapa log tentang kegagalan (screenshot, bugreport, logcat) di tingkat suite. Namun, untuk beberapa modul, log tertentu yang diminta mungkin tidak memiliki nilai apa pun dan hanya akan membuang waktu untuk dikumpulkan. Dalam situasi tersebut, modul dapat secara eksplisit
menentukan log yang diinginkan:
<object type="module_controller"
class="com.android.tradefed.testtype.suite.module.TestFailureModuleController">
<option name="screenshot-on-failure" value="<true OR false>" />
<option name="bugreportz-on-failure" value="<true OR false>" />
<option name="logcat-on-failure" value="<true OR false>" />
</object>
CATATAN: Implementasi pengontrol harus bersifat umum jika memungkinkan untuk
memaksimalkan penggunaan kembali. Selain itu, melewati modul berdasarkan kondisinya harus
ditinjau oleh pemilik modul untuk mendapatkan persetujuan bahwa melewati modul adalah
perilaku yang tepat bagi mereka.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# Employ module controllers\n\nEach suite module (defined by `AndroidTest.xml`) can contain a special\n`module_controller` object that can alter some behavior of the module:\n\nWhether to run the module or not based on some conditions\n---------------------------------------------------------\n\nBy implementing [BaseModuleController](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/suite/module/BaseModuleController.java)\nand adding it to the `AndroidTest.xml` like this: \n\n \u003cobject type=\"module_controller\" class=\"com.android.tradefed.testtype.suite.module.\u003cNAME\u003e\" /\u003e\n\nThe module controller will be used to determine whether the module should run\nor not, based on the\n`public abstract RunStrategy shouldRun(IInvocationContext context);`\nimplementation.\n\nWhether to collect some logs or not on failures\n-----------------------------------------------\n\nWhen running a full suite, it's possible to request at the suite level the\ncollection of some logs on failures (screenshot, bugreport, logcat). But for\nsome modules, a particular log requested might not have any value and will\nsimply waste time to be collected. In that situation, a module can explicitly\nspecify which logs they are interested in: \n\n \u003cobject type=\"module_controller\"\n class=\"com.android.tradefed.testtype.suite.module.TestFailureModuleController\"\u003e\n \u003coption name=\"screenshot-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003coption name=\"bugreportz-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003coption name=\"logcat-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003c/object\u003e\n\nNOTE: Implementation of controllers should be generic if possible in order to\nmaximize re-usability. And skipping a module based on its condition should\nbe reviewed by the module owner to get the approval that skipping a module is\nthe proper behavior for them."]]