2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
自動化 CTS テストを実行する(Android 11 以降)
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
CTS 自動テストを実行するには、次の 2 つの方法があります。
このページでは、Trade Federation を使用して自動テストを実行する方法について説明します。OmniLab Android テストハーネスを使用してテストを実行する手順については、OmniLab Android Test Station をご覧ください。
すべての自動化 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 自動テストが実行されます。次の点にご注意ください。
Android 13 以降では、マルチデバイス テストがサポートされています。これらのテストは、シャーディングが使用されている場合にのみ自動的に実行されます。シャーディングの詳細については、テスト実行時間を短縮するをご覧ください。これらのテストを手動で実行する場合は、マルチデバイス テストを実行するをご覧ください。
CTS を実行するたびに、Ctrl+C キーを押して既存の CTS コンソールを停止し、CTS コンソールを再実行します。
複数の CTS バージョンを 1 つのホスト上で実行することはできません。各 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]
など)が末尾に付加されます。
マルチデバイス テストを実行する
次のコマンドを実行して、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
コマンドを使用してテスト実行時間を短縮できます。このコマンドを使用すると、前提条件、デバイス情報の収集、すべてのシステム状態チェッカーがスキップされます。また、1 つの ABI のみでテストを実行します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-05-08 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-05-08 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."]]