ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ใช้ตัวควบคุมโมดูล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
โมดูลชุดแต่ละรายการ (กำหนดโดย AndroidTest.xml
) อาจมีออบเจ็กต์ module_controller
พิเศษที่เปลี่ยนแปลงลักษณะการทํางานบางอย่างของโมดูลได้ ดังนี้
เงื่อนไขในการพิจารณาว่าจะเรียกใช้โมดูลหรือไม่
โดยใช้ BaseModuleController และเพิ่มลงใน AndroidTest.xml
ดังนี้
<object type="module_controller" class="com.android.tradefed.testtype.suite.module.<NAME>" />
ระบบจะใช้ตัวควบคุมโมดูลเพื่อพิจารณาว่าควรเรียกใช้โมดูลหรือไม่ โดยอิงตามการใช้งาน public abstract RunStrategy shouldRun(IInvocationContext context);
รวบรวมบันทึกบางส่วนหรือไม่ในกรณีที่ดำเนินการไม่สำเร็จ
เมื่อเรียกใช้ชุดทดสอบทั้งหมด คุณสามารถขอรวบรวมบันทึกบางอย่างเกี่ยวกับข้อผิดพลาด (ภาพหน้าจอ รายงานข้อบกพร่อง logcat) ในระดับชุดทดสอบได้ แต่สําหรับข้อบังคับบางอย่าง บันทึกที่ขออาจไม่มีค่าใดๆ และจะเป็นการเสียเวลาในการรวบรวม ในกรณีนี้ โมดูลจะระบุบันทึกที่ต้องการได้อย่างชัดเจน ดังนี้
<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>
หมายเหตุ: การติดตั้งใช้งานตัวควบคุมควรเป็นแบบทั่วไปหากเป็นไปได้เพื่อเพิ่มความสามารถในการนํากลับมาใช้ซ้ำให้ได้สูงสุด และเจ้าของข้อบังคับควรตรวจสอบการข้ามข้อบังคับตามเงื่อนไขเพื่อขออนุมัติว่าการข้ามข้อบังคับเป็นลักษณะการทำงานที่เหมาะสม
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 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."]]