ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
สร้างเครื่องมือรายงานผล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หน้านี้อธิบายพื้นฐานเกี่ยวกับวิธีใช้เครื่องมือรายงานผลลัพธ์ใหม่และกำหนดค่าสำหรับการทดสอบ
อินเทอร์เฟซหลัก
หากต้องการกำหนดเครื่องมือรายงานผลลัพธ์ใหม่ใน Tradefed ชั้นเรียนต้องใช้งานITestInvocationListener
อินเทอร์เฟซที่อนุญาตให้รับและจัดการการเรียกใช้ในแต่ละระยะ ดังนี้
invocationStarted
invocationEnded
invocationFailed
นอกจากนี้ เครื่องมือรายงานผลลัพธ์ยังจัดการกับระยะต่างๆ ของการทดสอบแต่ละครั้งด้วย
testRunStarted
testStarted
testFailed
หรือ testIgnored
testEnded
testRunFailed
testRunEnded
เหตุการณ์ทั้งหมดเหล่านี้ส่งผลให้ผู้รายงานผลลัพธ์มี 2 ประเภทหลักๆ ดังนี้
- สนใจเฉพาะการรายงานผลลัพธ์สุดท้ายที่สมบูรณ์
- ดำเนินการกับผลการค้นหาบางส่วน
ผู้รายงานผลลัพธ์ที่รายงานผลลัพธ์สุดท้ายที่สมบูรณ์
ประเภทนี้เป็นกรณีที่พบบ่อยที่สุดเมื่อต้องโต้ตอบกับบริการภายนอกที่รับผลลัพธ์ ผู้รายงานเพียงแค่รับและรวบรวมผลลัพธ์ แล้วส่งทั้งหมดใน invocationEnded
ไปยังปลายทางของผลลัพธ์
เราขอแนะนำให้ผู้รายงานเหล่านั้นขยาย CollectingTestListener
แทนอินเทอร์เฟซพื้นฐานเพื่อหลีกเลี่ยงการติดตั้งใช้งานการบันทึกและจัดเก็บผลลัพธ์อีกครั้งจนถึง invocationEnded
ผู้รายงานผลลัพธ์ที่รายงานผลลัพธ์บางส่วน
ประเภทนี้มักใช้กับวิธีการสตรีมผลลัพธ์ เมื่อได้รับผลลัพธ์และส่งไปยังที่อื่นทันที เช่น ผู้รายงานที่บันทึกผลลัพธ์ลงในคอนโซลจะจัดอยู่ในประเภทนี้
ประเภทนี้ใช้กับประเภทการจัดการที่จำเป็นสำหรับเหตุการณ์ ดังนั้นโดยทั่วไปแล้วเราขอแนะนำให้ใช้อินเทอร์เฟซพื้นฐาน
การกําหนดค่า XML
แท็กออบเจ็กต์คือ result_reporter
เช่น
<result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
<option name="suppress-passed-tests" value="true"/>
</result_reporter>
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# 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"]]