यूज़र इंटरफ़ेस (यूआई) के व्यवहार से जुड़े टेस्ट
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यूज़र इंटरफ़ेस (यूआई) के व्यवहार की जांच करने वाले टेस्ट, यूआई के लेआउट का विश्लेषण करते हैं, ताकि यूआई एलिमेंट की प्रॉपर्टी के बारे में दावे किए जा सकें.
Jetpack फ़्रेमवर्क
Jetpack में कई फ़्रेमवर्क शामिल हैं, जो यूज़र इंटरफ़ेस (यूआई) टेस्ट लिखने के लिए एपीआई उपलब्ध कराते हैं:
- Espresso टेस्टिंग फ़्रेमवर्क (Android 4.0.1, एपीआई लेवल 14 या इससे पहले का वर्शन) में यूज़र इंटरैक्शन को सिम्युलेट करने के लिए, यूज़र इंटरफ़ेस (यूआई) टेस्ट लिखने के लिए एपीआई उपलब्ध होते हैं. ऐसा, टारगेट किए गए किसी एक ऐप्लिकेशन में व्यू के साथ किया जाता है. Espresso का इस्तेमाल करने का एक मुख्य फ़ायदा यह है कि यह टेस्ट ऐक्शन को, टेस्ट किए जा रहे ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) के साथ अपने-आप सिंक करता है. एस्प्रेसो पता लगाता है कि मुख्य थ्रेड कुछ समय से इस्तेमाल में नहीं है. इससे, यह जांच के निर्देशों को सही समय पर चला पाता है. इससे, आपकी जांच पर ज़्यादा भरोसा होता है.
- Jetpack Compose (Android 5.0, एपीआई लेवल 21 या उसके बाद के वर्शन), Compose स्क्रीन और कॉम्पोनेंट को लॉन्च करने और उनसे इंटरैक्ट करने के लिए, टेस्टिंग एपीआई का एक सेट उपलब्ध कराता है. Compose एलिमेंट के साथ इंटरैक्शन, टेस्ट के साथ सिंक होते हैं. साथ ही, इन पर समय, ऐनिमेशन, और फिर से कॉम्पोज़ करने का पूरा कंट्रोल होता है.
- यूज़र इंटरफ़ेस Automator (Android 4.3, एपीआई लेवल 18 या उसके बाद के वर्शन) एक यूज़र इंटरफ़ेस (यूआई) टेस्टिंग फ़्रेमवर्क है. यह सिस्टम और इंस्टॉल किए गए सभी ऐप्लिकेशन में, क्रॉस-ऐप्लिकेशन फ़ंक्शनल यूज़र इंटरफ़ेस (यूआई) टेस्टिंग के लिए सही है. UI Automator API की मदद से, टेस्ट डिवाइस पर सेटिंग मेन्यू या ऐप्लिकेशन लॉन्चर खोलने जैसे काम किए जा सकते हैं.
- Robolectric (Android 4.1, एपीआई लेवल 16 या इसके बाद का वर्शन) की मदद से, लोकल टेस्ट बनाए जा सकते हैं. ये टेस्ट, एमुलेटर या डिवाइस के बजाय, आपके वर्कस्टेशन या सीआई (कंटिन्यूअस इंटिग्रेशन) एनवायरमेंट में, सामान्य JVM में चलते हैं. यह यूज़र इंटरफ़ेस (यूआई) कॉम्पोनेंट के साथ इंटरैक्ट करने के लिए, Espresso या Compose टेस्टिंग एपीआई का इस्तेमाल कर सकता है.
अन्य संसाधन
यूज़र इंटरफ़ेस (यूआई) टेस्ट बनाने के बारे में ज़्यादा जानने के लिए, नीचे दिए गए संसाधन देखें.
दस्तावेज़
कोडलैब
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (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-27 (UTC) को अपडेट किया गया."],[],[],null,["# Behavior UI Tests\n\nBehavior UI tests are tests that analyze the UI hierarchy to make assertions\non the properties of the UI elements.\n\nJetpack frameworks\n------------------\n\nJetpack includes various frameworks that provide APIs for writing UI tests:\n\n- The **[Espresso testing framework](/training/testing/espresso)** (Android 4.0.1, API level 14 or higher) provides APIs for writing UI tests to simulate user interactions with *Views* within a single target app. A key benefit of using Espresso is that it provides automatic synchronization of test actions with the UI of the app you are testing. Espresso detects when the main thread is idle, so it is able to run your test commands at the appropriate time, improving the reliability of your tests.\n- **[Jetpack Compose](/jetpack/compose)** (Android 5.0, API level 21 or higher) provides a set of [*testing APIs*](/jetpack/compose/testing) to launch and interact with Compose screens and components. Interactions with Compose elements are synchronized with tests and have complete control over time, animations and recompositions.\n- **[UI Automator](/training/testing/ui-automator)** (Android 4.3, API level 18 or higher) is a UI testing framework suitable for cross-app functional UI testing across system and installed apps. The UI Automator APIs allows you to perform operations such as opening the Settings menu or the app launcher on a test device.\n- **[Robolectric](/training/testing/local-tests/robolectric)** (Android 4.1, API level 16 or higher) lets you create *local* tests that run on your workstation or continuous integration environment in a regular JVM, instead of on an emulator or device. It can use Espresso or Compose testing APIs to interact with UI components.\n\nAdditional resources\n--------------------\n\nFor more information about creating UI tests, consult the following resources.\n\n### Documentation\n\n- [Build instrumented tests](/training/testing/instrumented-tests)\n- [Espresso](/training/testing/espresso)\n- [Compose Testing](/jetpack/compose/testing)\n\n### Codelabs\n\n- [Introduction to Test Doubles and Dependency Injection](/codelabs/advanced-android-kotlin-training-testing-test-doubles)"]]