ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
เรียกใช้การทดสอบอัตโนมัติ (Android 11 ขึ้นไป)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การเรียกใช้การทดสอบอัตโนมัติของ CTS มี 2 ตัวเลือก ได้แก่
Trade Federation เป็นแอปและเฟรมเวิร์กการทดสอบที่ช่วยให้คุณเรียกใช้การทดสอบจากบรรทัดคำสั่งได้ โดยพื้นฐานแล้ว เฟรมเวิร์กนี้จะช่วยให้คุณกำกับเนื้อหาการทดสอบได้โดยใช้คำอธิบายประกอบ @Test
จากนั้นแอปจะค้นหาและเรียกใช้การทดสอบเหล่านั้น
OmniLab Android Test Station เป็นแอปที่ช่วยให้คุณทำการทดสอบใน GUI ได้
หน้านี้จะอธิบายวิธีเรียกใช้การทดสอบอัตโนมัติโดยใช้ Trade Federation ดูวิธีการทดสอบโดยใช้ OmniLab Android Test Harness ได้ที่สถานีทดสอบ Android ของ OmniLab
เรียกใช้การทดสอบ CTS แบบอัตโนมัติทั้งหมด
Trade Federation มีคอนโซล CTS ซึ่งเป็นอินเทอร์เฟซบรรทัดคำสั่งสำหรับการเรียกใช้การทดสอบ วิธีเรียกใช้ชุดทดสอบ CTS แบบอัตโนมัติทั้งหมด
- ตรวจสอบว่าคุณได้ทำตามวิธีการในหัวข้อตั้งค่าการทดสอบอัตโนมัติ CTS
ในเวิร์กสเตชันทดสอบ ให้เปิดคอนโซล CTS โดยเรียกใช้สคริปต์ cts-tradefed
จากโฟลเดอร์ที่แตกไฟล์ ZIP ของ CTS แล้ว
./android-cts/tools/cts-tradefed
คอนโซล CTS จะแสดงเคอร์เซอร์ให้คุณพิมพ์คําสั่ง CTS (cts-tradefed >
)
แผนทดสอบ cts
มีการทดสอบ CTS แบบอัตโนมัติทั้งหมด เรียกใช้คำสั่งต่อไปนี้เพื่อเรียกใช้แผนการทดสอบ cts
run cts
การทดสอบ CTS แบบอัตโนมัติจะทำงาน ข้อควรทราบ
Android 13 ขึ้นไปรองรับการทดสอบหลายอุปกรณ์ การทดสอบเหล่านี้จะทํางานโดยอัตโนมัติก็ต่อเมื่อมีการใช้การแยกข้อมูลเท่านั้น ดูข้อมูลเพิ่มเติมเกี่ยวกับการจัดสรรได้ที่ปรับปรุงเวลาในการเรียกใช้การทดสอบ หากต้องการเรียกใช้การทดสอบเหล่านี้ด้วยตนเอง โปรดดูเรียกใช้การทดสอบหลายอุปกรณ์
เมื่อใดก็ตามที่เรียกใช้ CTS ให้กด ctrl+c เพื่อหยุดคอนโซล CTS ที่มีอยู่ แล้วเรียกใช้คอนโซล CTS อีกครั้ง
คุณไม่สามารถเรียกใช้ CTS หลายเวอร์ชันในโฮสต์เดียวได้ เนื่องจากแต่ละเวอร์ชันจะเปิดขึ้นด้วยเซิร์ฟเวอร์รหัสตำแหน่งแบบเปิด (OLC) ที่มีอยู่
ดูผลการทดสอบ ดูข้อมูลเพิ่มเติมได้ที่ตีความผลลัพธ์ CTS
หากนี่เป็นการทดสอบครั้งแรก การทดสอบอาจล้มเหลวเนื่องจากปัญหาที่อยู่นอกเหนือการควบคุมของคุณ เช่น การเชื่อมต่อเครือข่ายอาจช้าหรือสัญญาณ GPS อาจอ่อน เรียกใช้การทดสอบซ้ำ (ลองใหม่) จนกว่าโมดูลการทดสอบทั้งหมดจะเสร็จสมบูรณ์ และจำนวนการทดสอบที่ไม่ผ่านเหมือนกันระหว่างเซสชันการลองใหม่ 2 รายการล่าสุด
run retry --retry session_number`
หลังจากการทดสอบล้มเหลวอย่างต่อเนื่องในการลองอีกครั้ง ให้มุ่งเน้นที่การแก้ไขข้อบกพร่องของการทดสอบที่เหลือซึ่งไม่ผ่าน ดูข้อมูลเกี่ยวกับการแก้ปัญหาผลลัพธ์การทดสอบได้ที่หัวข้อจัดประเภทการทดสอบที่ไม่ผ่านและแก้ปัญหาการทดสอบ CTS
เรียกใช้ CTS สำหรับอุปกรณ์หลายหน้าจอ
หากอุปกรณ์ใช้ Android 11 หรือ 12 และมีหน้าจอหลายหน้าจอ คุณต้องเรียกใช้แผนการทดสอบ cts-foldable
แยกต่างหาก โดยทำดังนี้
run cts-foldable
เทสเคสที่ผ่านหรือไม่ผ่านสําหรับโหมดหน้าจออื่นจะเพิ่มค่าจาก display_mode
ต่อท้าย เช่น testcase1[display_mode=0]
ทำการทดสอบหลายอุปกรณ์ (Android 15 หรือต่ำกว่า)
เรียกใช้คำสั่งต่อไปนี้เพื่อเรียกใช้แผนการทดสอบ cts-multidevice
run cts-multidevice
เรียกใช้แผนการทดสอบแต่ละรายการ
คุณสามารถเรียกใช้แผนการทดสอบแต่ละรายการแทนการเรียกใช้แผนการทดสอบทั้งหมดพร้อมกันได้
ตัวเลือกนี้มีประโยชน์ในการประหยัดเวลาและมุ่งเน้นที่ชุดการทดสอบที่เฉพาะเจาะจง
วิธีเรียกใช้แผนการทดสอบแต่ละรายการ
ระบุชื่อแผนการทดสอบที่ต้องการเรียกใช้โดยเรียกใช้คําสั่ง list modules
เรียกใช้แผนทดสอบ
run cts --plan test_module_or_plan_name
ปรับปรุงเวลาในการเรียกใช้การทดสอบ
หากต้องการปรับปรุงเวลาในการเรียกใช้การทดสอบ คุณสามารถแบ่งการทดสอบในอุปกรณ์หลายเครื่อง การแยกข้อมูลกำหนดให้โฮสต์ต้องเชื่อมต่ออุปกรณ์อย่างน้อย 2 เครื่อง แต่เราขอแนะนำให้ใช้อุปกรณ์อย่างน้อย 6 เครื่องเพื่อให้มีประสิทธิภาพ
หากต้องการแบ่งกลุ่มการทดสอบใน Android 11 ขึ้นไป ให้เรียกใช้คำสั่งต่อไปนี้
run cts --shard-count number_of_shards
นอกจากนี้ ก่อนทำการทดสอบเพื่อตรวจสอบ คุณสามารถปรับปรุงเวลาในการเรียกใช้การทดสอบได้โดยใช้คําสั่ง CTS run cts-dev
คำสั่งนี้จะข้ามเงื่อนไขเบื้องต้น การเก็บรวบรวมข้อมูลอุปกรณ์ และเครื่องมือตรวจสอบสถานะระบบทั้งหมด
รวมถึงจะทำการทดสอบกับ ABI เพียงรายการเดียวเท่านั้น
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-30 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-30 UTC"],[],[],null,["# Run automated tests (Android 11 or higher)\n\nThere are two options for running CTS automated tests:\n\n- *Trade Federation* is an app and test framework that lets you\n run tests from the command line. Fundamentally, the framework\n lets you annotate tests using the `@Test` annotation and the app finds and runs\n those tests.\n\n- *OmniLab Android Test Station* is an app that lets you run tests\n in a GUI.\n\nThis page explains how to run automated tests using Trade Federation. For\ninstructions on running tests using OmniLab Android Test Harness, see\n[OmniLab Android Test Station](/docs/core/tests/development/android-test-station/ats-user-guide).\n\nRun all automated CTS tests\n---------------------------\n\nTrade Federation contains the *CTS console*, a command-line interface for\nrunning tests. To run the entire automated CTS test suite:\n\n1. Ensure you have followed the instructions in [Set up CTS automated testing](/docs/compatibility/cts/setup).\n2. On your test workstation, launch the CTS console by running the `cts-tradefed` script from the folder where the CTS package has been unzipped:\n\n ./android-cts/tools/cts-tradefed\n\n The CTS console displays a cursor for you to type CTS commands\n (`cts-tradefed \u003e`).\n3. The `cts` test plan contains all of the automated CTS tests. Execute the\n following command to run the `cts` test plan:\n\n run cts\n\n The automated CTS tests execute. Note the following:\n - Android 13 and higher support multidevice testing. These tests run\n automatically only when sharding is used. For further information on sharding,\n see [Improve test execution time](#improve). If you want to run these tests\n manually, see [Run multidevice tests](#multi-device-testing).\n\n - Whenever running CTS, press **ctrl+c** to stop the existing CTS console\n and then rerun the CTS console.\n\n - You can't run multiple CTS versions on single host because each opens\n with an existing open location code (OLC) server.\n\n4. View test results. For more information, see [Interpret CTS results](/docs/compatibility/cts/interpret).\n\n5. If this is your first test run, there might be tests that fail due to issues beyond your control. For example, a network connection might be slow or a GPS signal might be weak. Rerun (retry) the tests until all test modules are completed and the test failure numbers are the same between the last two retry sessions:\n\n run retry --retry \u003cvar translate=\"no\"\u003esession_number\u003c/var\u003e`\n\n | **Note:** For implementation details for CTS retry, see [Use suite retry](/docs/core/tests/tradefed/testing/through-suite/suite-retry).\n | **Note:** For instructions on how to run a retry session on Android 10 or lower, see [Run CTS automated tests (AOSP 10 or lower)](/docs/compatibility/cts/run-older).\n6. After tests failures are consistent across retries, focus on debugging\n the remaining failed tests. For information on troubleshooting test\n results, see\n [Triage test failures](/docs/compatibility/cts/interpret#triaging-test-failures)\n and\n [Troubleshoot CTS tests](/docs/compatibility/cts/troubleshooting).\n\n| **Note:** For a list of all CTS console commands, see [CTS v2 command console](/compatibility/cts/command-console-v2).\n\nRun CTS for multiscreen devices\n-------------------------------\n\nIf your device is running Android 11 or 12, and your device has multiple\nscreens, you must run the `cts-foldable` test plan separately: \n\n run cts-foldable\n\nPassed or failed test cases for alternate screen mode are appended with the\nvalue from `display_mode`, for example, `testcase1[display_mode=0]`.\n| **Note:** For instructions on how to run the `cts-foldable` test plan for Android 10 or lower, see [Run CTS automated tests (Android 10 or lower)](/docs/compatibility/cts/run-older).\n\nRun multidevice tests (Android 15 or lower)\n-------------------------------------------\n\nExecute the following command to run the `cts-multidevice` test plan: \n\n run cts-multidevice\n\nRun individual test plans\n-------------------------\n\nInstead of running all test plans at once, you can run individual test plans.\nThis option is useful to save time and to focus on a specific set of tests.\nTo run an individual test plan:\n\n1. Identify the name of the test plan you want to run by executing the `list modules` command.\n\n | **Note:** For instructions on how to identify the module on Android 10 or lower, see [Run CTS automated tests (Android 10 or lower)](/docs/compatibility/cts/run-older).\n2. Run the test plan:\n\n run cts --plan \u003cvar translate=\"no\"\u003etest_module_or_plan_name\u003c/var\u003e\n\nImprove test execution time\n---------------------------\n\nIf you want to improve test execution time, you can shard tests across multiple\ndevices. Sharding requires the host to connect at least two devices, but six or\nmore devices are recommended for efficiency.\n\nTo shard tests on Android 11 or higher, run: \n\n run cts --shard-count \u003cvar translate=\"no\"\u003enumber_of_shards\u003c/var\u003e\n\nAdditionally, before running your tests for validation you can improve test\nexecution time by using the CTS `run cts-dev` command. This command skips\npreconditions, device-information collection, and all system status checkers.\nIt also runs the tests on only a single ABI."]]