از 27 مارس 2025، توصیه می کنیم از android-latest-release
به جای aosp-main
برای ساختن و کمک به AOSP استفاده کنید. برای اطلاعات بیشتر، به تغییرات AOSP مراجعه کنید.
اجرای تستهای خودکار (اندروید 11 یا بالاتر)، اجرای آزمایشهای خودکار (اندروید 11 یا بالاتر)
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
دو گزینه برای اجرای تست های خودکار CTS وجود دارد:
Trade Federation یک برنامه و چارچوب آزمایشی است که به شما امکان می دهد تست ها را از خط فرمان اجرا کنید. اساساً، این چارچوب به شما امکان میدهد با استفاده از حاشیهنویسی @Test
تستها را حاشیهنویسی کنید و برنامه آن تستها را پیدا کرده و اجرا میکند.
OmniLab Android Test Station برنامه ای است که به شما امکان می دهد آزمایش ها را در یک رابط کاربری گرافیکی اجرا کنید.
این صفحه نحوه اجرای تست های خودکار با استفاده از Trade Federation را توضیح می دهد. برای دستورالعملهای مربوط به اجرای آزمایشها با استفاده از مهار تست اندروید OmniLab، به ایستگاه تست اندروید OmniLab مراجعه کنید.
تمام تست های CTS خودکار را اجرا کنید
Trade Federation شامل کنسول CTS است که یک رابط خط فرمان برای اجرای آزمایشات است. برای اجرای کل مجموعه تست خودکار CTS:
- مطمئن شوید که دستورالعملهای موجود در تنظیم تست خودکار CTS را دنبال کردهاید.
در ایستگاه کاری آزمایشی خود، کنسول CTS را با اجرای اسکریپت cts-tradefed
از پوشه ای که بسته CTS در آن از حالت فشرده خارج شده است، راه اندازی کنید:
./android-cts/tools/cts-tradefed
کنسول CTS مکان نما را برای شما نمایش می دهد تا دستورات CTS را تایپ کنید ( cts-tradefed >
).
طرح تست cts
شامل تمام تست های خودکار CTS است. برای اجرای طرح تست cts
دستور زیر را اجرا کنید:
run cts
تست های CTS خودکار اجرا می شوند. به موارد زیر توجه کنید:
اندروید 13 و بالاتر از تست چند دستگاهی پشتیبانی می کند. این تستها بهطور خودکار فقط در صورت استفاده از اشتراکگذاری اجرا میشوند. برای اطلاعات بیشتر در مورد اشتراک گذاری، به بهبود زمان اجرای آزمایش مراجعه کنید. اگر میخواهید این آزمایشها را به صورت دستی اجرا کنید، به اجرای آزمایشهای چند دستگاهی مراجعه کنید.
هر زمان که CTS را اجرا می کنید، ctrl+c را فشار دهید تا کنسول CTS موجود متوقف شود و سپس کنسول CTS را دوباره اجرا کنید.
شما نمی توانید چندین نسخه CTS را روی یک هاست اجرا کنید زیرا هر کدام با یک سرور کد مکان باز موجود (OLC) باز می شوند.
مشاهده نتایج آزمون برای اطلاعات بیشتر، به تفسیر نتایج CTS مراجعه کنید.
اگر این اولین اجرای آزمایشی شماست، ممکن است تست هایی وجود داشته باشد که به دلیل مسائلی که خارج از کنترل شما هستند، با شکست مواجه شوند. برای مثال، اتصال شبکه ممکن است کند باشد یا سیگنال GPS ضعیف باشد. تستها را مجدداً اجرا کنید (دوباره امتحان کنید) تا زمانی که همه ماژولهای تست کامل شوند و اعداد شکست آزمون بین دو جلسه امتحان مجدد یکسان باشند:
run retry --retry session_number`
پس از اینکه شکستهای تستها در طول تلاشهای مجدد ثابت شد، روی اشکالزدایی تستهای ناموفق باقی مانده تمرکز کنید. برای اطلاعات در مورد عیبیابی نتایج آزمون، به شکستهای تست Triage و عیبیابی تستهای CTS مراجعه کنید.
CTS را برای دستگاه های چند صفحه ای اجرا کنید
اگر دستگاه شما دارای Android 11 یا 12 است و دستگاه شما دارای چندین صفحه است، باید برنامه آزمایشی cts-foldable
را جداگانه اجرا کنید:
run cts-foldable
موارد تست رد شده یا ناموفق برای حالت صفحه نمایش جایگزین با مقدار display_mode
اضافه می شود، به عنوان مثال، testcase1[display_mode=0]
.
اجرای تست های چند دستگاهی (اندروید 15 یا پایین تر)
برای اجرای برنامه آزمایشی cts-multidevice
دستور زیر را اجرا کنید:
run cts-multidevice
برنامه های تست فردی را اجرا کنید
به جای اجرای همه برنامه های آزمایشی به طور همزمان، می توانید برنامه های آزمایشی فردی را اجرا کنید. این گزینه برای صرفه جویی در زمان و تمرکز بر روی مجموعه خاصی از تست ها مفید است. برای اجرای طرح آزمایشی فردی:
با اجرای دستور list modules
نام برنامه آزمایشی را که می خواهید اجرا کنید مشخص کنید.
طرح تست را اجرا کنید:
run cts --plan test_module_or_plan_name
بهبود زمان اجرای آزمون
اگر میخواهید زمان اجرای آزمایش را بهبود ببخشید، میتوانید آزمایشها را در چندین دستگاه تقسیم کنید. Sharding به میزبان نیاز دارد که حداقل دو دستگاه را متصل کند، اما شش دستگاه یا بیشتر برای کارایی توصیه می شود.
برای اشتراکگذاری تستها در Android 11 یا بالاتر، اجرا کنید:
run cts --shard-count number_of_shards
علاوه بر این، قبل از اجرای آزمایشهای خود برای اعتبارسنجی، میتوانید با استفاده از دستور CTS run cts-dev
زمان اجرای آزمایش را بهبود بخشید. این دستور از پیششرطها، جمعآوری اطلاعات دستگاه و همه بررسیکنندههای وضعیت سیستم صرفنظر میکند. همچنین تست ها را تنها روی یک ABI اجرا می کند.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-30 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]