デバッグテスト
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
テストで問題を解決する主な方法は、セマンティクス ツリーを確認することです。テストの任意の時点で composeTestRule.onRoot().printToLog()
を呼び出すことで、ツリーを出力できます。この関数は次のようなログを出力します。
Node #1 at (...)px
|-Node #2 at (...)px
OnClick = '...'
MergeDescendants = 'true'
|-Node #3 at (...)px
| Text = 'Hi'
|-Node #5 at (83.0, 86.0, 191.0, 135.0)px
Text = 'There'
こうしたログには、バグを追跡するための貴重な情報が含まれています。
参考情報
- Android でアプリをテストする: Android テストのメイン ランディング ページでは、テストの基礎と手法についてより広範な視点から説明しています。
- テストの基礎: Android アプリのテストの背景にある基本概念について詳しく学びます。
- ローカルテスト: 一部のテストは、自分のワークステーションでローカルに実行できます。
- インストゥルメント化テスト: インストゥルメント化テストも実行することをおすすめします。つまり、デバイス上で直接実行されるテストです。
- 継続的インテグレーション:
継続的インテグレーションを使用すると、テストをデプロイ パイプラインに統合できます。
- さまざまな画面サイズをテストする: ユーザーが利用できるデバイスは多種多様であるため、さまざまな画面サイズでテストする必要があります。
- Espresso: View ベースの UI を対象としていますが、Espresso の知識は Compose テストのいくつかの側面で役立ちます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-09-03 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-09-03 UTC。"],[],[],null,["The main way to solve problems in your tests is to look at the semantics tree.\nPrint the tree by calling `composeTestRule.onRoot().printToLog()` at\nany point in your test. This function prints a log like this: \n\n Node #1 at (...)px\n |-Node #2 at (...)px\n OnClick = '...'\n MergeDescendants = 'true'\n |-Node #3 at (...)px\n | Text = 'Hi'\n |-Node #5 at (83.0, 86.0, 191.0, 135.0)px\n Text = 'There'\n\nThese logs contain valuable information for tracking bugs down.\n\nAdditional Resources\n\n- **[Test apps on Android](/training/testing)**: The main Android testing landing page provides a broader view of testing fundamentals and techniques.\n- **[Fundamentals of testing](/training/testing/fundamentals):** Learn more about the core concepts behind testing an Android app.\n- **[Local tests](/training/testing/local-tests):** You can run some tests locally, on your own workstation.\n- **[Instrumented tests](/training/testing/instrumented-tests):** It is good practice to also run instrumented tests. That is, tests that run directly on-device.\n- **[Continuous integration](/training/testing/continuous-integration):** Continuous integration lets you integrate your tests into your deployment pipeline.\n- **[Test different screen sizes](/training/testing/different-screens):** With some many devices available to users, you should test for different screen sizes.\n- **[Espresso](/training/testing/espresso)**: While intended for View-based UIs, Espresso knowledge can still be helpful for some aspects of Compose testing."]]