החל מ-27 במרץ 2025, מומלץ להשתמש ב-android-latest-release
במקום ב-aosp-main
כדי ליצור תרומות ל-AOSP. מידע נוסף זמין במאמר שינויים ב-AOSP.
הפעלת בדיקות אוטומטיות (Android מגרסה 11 ואילך)
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
יש שתי אפשרויות להרצת בדיקות אוטומטיות של CTS:
Trade Federation היא מסגרת לאפליקציות ולבדיקות שמאפשרת להריץ בדיקות משורת הפקודה. ביסודו, המסגרת מאפשרת להוסיף הערות לבדיקות באמצעות ההערה @Test
, והאפליקציה מאתרת את הבדיקות האלה ומריצה אותן.
OmniLab Android Test Station היא אפליקציה שמאפשרת להריץ בדיקות בממשק משתמש גרפי.
בדף הזה מוסבר איך להריץ בדיקות אוטומטיות באמצעות Trade Federation. להוראות להרצת בדיקות באמצעות OmniLab Android Test Harness, ראו OmniLab Android Test Station.
הפעלת כל הבדיקות האוטומטיות של CTS
Trade Federation מכיל את מסוף CTS, ממשק שורת פקודה להרצת בדיקות. כדי להריץ את כל חבילת הבדיקות האוטומטיות של CTS:
- חשוב לוודא שפעלתם לפי ההוראות במאמר הגדרת בדיקות אוטומטיות של CTS.
בתחנת העבודה לבדיקה, מריצים את הסקריפט cts-tradefed
מהתיקייה שבה חבילה 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 חלשה. מריצים מחדש (מנסים שוב) את הבדיקות עד שכל המודולים של הבדיקות יושלמו ומספרי הכשל בבדיקה זהים בין שתי סשנים האחרונים של הניסיון החוזר:
run retry --retry session_number`
אם הבדיקות נכשלות באופן עקבי בניסיונות חוזרים, כדאי להתמקד בניפוי באגים של הבדיקות שנכשלו. למידע על פתרון בעיות בתוצאות הבדיקה, תוכלו לקרוא את המאמרים Triage test failures ו-Troubleshoot CTS tests.
הפעלת 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
שיפור זמן ביצוע הבדיקה
כדי לשפר את זמן ביצוע הבדיקה, אפשר לפצל את הבדיקות לכמה מכשירים. כדי לבצע חלוקה למקטעים, המארח צריך לחבר לפחות שני מכשירים, אבל מומלץ לחבר שישה מכשירים או יותר כדי לשפר את היעילות.
כדי לפצל בדיקות ב-Android מגרסה 11 ואילך, מריצים את הפקודה:
run cts --shard-count number_of_shards
בנוסף, לפני שמריצים את הבדיקות לאימות, אפשר לשפר את זמן הביצוע של הבדיקות באמצעות הפקודה run cts-dev
של CTS. הפקודה הזו מדלגת על התנאים המוקדמים, על איסוף פרטי המכשיר ועל כל בודקי סטטוס המערכת.
בנוסף, הבדיקה מתבצעת רק ב-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."]]