উভয় প্রকারের সাথে মিল করার জন্য কোন বিশেষ পদক্ষেপের প্রয়োজন নেই। আপনি Espresso এর onView সাথে ভিউ এবং ComposeTestRule সাথে কম্পোজ এলিমেন্টের সাথে মিল রাখেন।
@TestfunandroidViewInteropTest(){// Check the initial state of a TextView that depends on a Compose state.Espresso.onView(withText("Hello Views")).check(matches(isDisplayed()))// Click on the Compose button that changes the state.composeTestRule.onNodeWithText("Click here").performClick()// Check the new value.Espresso.onView(withText("Hello Compose")).check(matches(isDisplayed()))}
UiAutomator এর সাথে ইন্টারঅপারেবিলিটি
ডিফল্টরূপে, কম্পোজেবলগুলি শুধুমাত্র তাদের সুবিধাজনক বর্ণনাকারী (প্রদর্শিত পাঠ্য, বিষয়বস্তুর বিবরণ ইত্যাদি) দ্বারা UiAutomator থেকে অ্যাক্সেসযোগ্য। আপনি যদি Modifier.testTag ব্যবহার করে এমন কোনো কম্পোজেবল অ্যাক্সেস করতে চান, তাহলে আপনাকে নির্দিষ্ট কম্পোজেবলের সাবট্রির জন্য শব্দার্থিক সম্পত্তি testTagsAsResourceId সক্ষম করতে হবে। এই আচরণটি সক্ষম করা কম্পোজেবলগুলির জন্য দরকারী যেগুলির অন্য কোনও অনন্য হ্যান্ডেল নেই, যেমন স্ক্রোলযোগ্য কম্পোজেবল (উদাহরণস্বরূপ, LazyColumn )।
Modifier.testTag সাথে সমস্ত নেস্টেড কম্পোজেবল UiAutomator থেকে অ্যাক্সেসযোগ্য তা নিশ্চিত করতে আপনার কম্পোজেবল অনুক্রমের উচ্চতায় শুধুমাত্র একবার শব্দার্থিক সম্পত্তি সক্ষম করুন।
Scaffold(// Enables for all composables in the hierarchy.modifier=Modifier.semantics{testTagsAsResourceId=true}){// Modifier.testTag is accessible from UiAutomator for composables nested here.LazyColumn(modifier=Modifier.testTag("myLazyColumn")){// Content}}
Modifier.testTag(tag) সাথে যেকোনও কম্পোজ করা যাবে resourceName মতো একই tag ব্যবহার করে By.res(resourceName) ব্যবহার করে অ্যাক্সেসযোগ্য।
valdevice=UiDevice.getInstance(getInstrumentation())vallazyColumn:UiObject2=device.findObject(By.res("myLazyColumn"))// Some interaction with the lazyColumn.
অতিরিক্ত সম্পদ
অ্যান্ড্রয়েডে অ্যাপ পরীক্ষা করুন : প্রধান অ্যান্ড্রয়েড টেস্টিং ল্যান্ডিং পৃষ্ঠাটি পরীক্ষার মৌলিক বিষয় এবং কৌশলগুলির একটি বিস্তৃত দৃশ্য প্রদান করে।
পরীক্ষার মৌলিক বিষয়গুলি : একটি Android অ্যাপ পরীক্ষা করার পিছনে মূল ধারণাগুলি সম্পর্কে আরও জানুন।
স্থানীয় পরীক্ষা : আপনি আপনার নিজস্ব ওয়ার্কস্টেশনে স্থানীয়ভাবে কিছু পরীক্ষা চালাতে পারেন।
ইন্সট্রুমেন্টেড পরীক্ষা : যন্ত্রযুক্ত পরীক্ষা চালানোও ভালো অভ্যাস। অর্থাৎ, যে পরীক্ষাগুলি সরাসরি ডিভাইসে চলে।
ক্রমাগত ইন্টিগ্রেশন : ক্রমাগত ইন্টিগ্রেশন আপনাকে আপনার পরীক্ষাগুলিকে আপনার স্থাপনার পাইপলাইনে একত্রিত করতে দেয়।
বিভিন্ন স্ক্রীনের মাপ পরীক্ষা করুন : ব্যবহারকারীদের জন্য উপলব্ধ কিছু অনেক ডিভাইসের সাথে, আপনার বিভিন্ন স্ক্রীন মাপের জন্য পরীক্ষা করা উচিত।
এসপ্রেসো : ভিউ-ভিত্তিক UI-এর উদ্দেশ্যে, Espresso জ্ঞান এখনও রচনা পরীক্ষার কিছু দিকগুলির জন্য সহায়ক হতে পারে।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-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-08-27 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Interoperability\n\nCompose integrates with common testing frameworks.\n\nInteroperability with Espresso\n------------------------------\n\nIn a hybrid app, you can find Compose components inside view hierarchies and\nviews inside Compose composables (via the [`AndroidView`](/reference/kotlin/androidx/compose/ui/viewinterop/package-summary#AndroidView(kotlin.Function1,androidx.compose.ui.Modifier,kotlin.Function1)) composable).\n\nThere are no special steps needed to match either type. You match views with\nEspresso's [`onView`](/reference/androidx/test/espresso/Espresso#onView(org.hamcrest.Matcher%3Candroid.view.View%3E)), and Compose elements with the [`ComposeTestRule`](/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule). \n\n @Test\n fun androidViewInteropTest() {\n // Check the initial state of a TextView that depends on a Compose state.\n Espresso.onView(withText(\"Hello Views\")).check(matches(isDisplayed()))\n // Click on the Compose button that changes the state.\n composeTestRule.onNodeWithText(\"Click here\").performClick()\n // Check the new value.\n Espresso.onView(withText(\"Hello Compose\")).check(matches(isDisplayed()))\n }\n\nInteroperability with UiAutomator\n---------------------------------\n\nBy default, composables are accessible from [UiAutomator](/training/testing/other-components/ui-automator) only by their\nconvenient descriptors (displayed text, content description, etc.). If you want\nto access any composable that uses [`Modifier.testTag`](/reference/kotlin/androidx/compose/ui/Modifier#(androidx.compose.ui.Modifier).testTag(kotlin.String)), you need to enable\nthe semantic property `testTagsAsResourceId` for the particular composable's\nsubtree. Enabling this behavior is useful for composables that don't have any\nother unique handle, such as scrollable composables (for example, `LazyColumn`).\n| **Note:** This feature is available in Jetpack Compose version 1.2.0-alpha08 and higher.\n\nEnable the semantic property only once high in your composables hierarchy to\nensure all nested composables with `Modifier.testTag` are accessible from\nUiAutomator. \n\n Scaffold(\n // Enables for all composables in the hierarchy.\n modifier = Modifier.semantics {\n testTagsAsResourceId = true\n }\n ){\n // Modifier.testTag is accessible from UiAutomator for composables nested here.\n LazyColumn(\n modifier = Modifier.testTag(\"myLazyColumn\")\n ){\n // Content\n }\n }\n\nAny composable with the `Modifier.testTag(tag)` can be accessible with the use\nof [`By.res(resourceName)`](/reference/androidx/test/uiautomator/BySelector#res) using the same `tag` as the `resourceName`.\n**Caution:** Make sure you don't use [`By.res(resourcePackage, resourceId)`](/reference/androidx/test/uiautomator/BySelector#res_1) as this formats the argument as `$resourcePackage:id/$resourceId`, which is different from `Modifier.testTag`. \n\n val device = UiDevice.getInstance(getInstrumentation())\n\n val lazyColumn: UiObject2 = device.findObject(By.res(\"myLazyColumn\"))\n // Some interaction with the lazyColumn.\n\nAdditional Resources\n--------------------\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."]]