مفاهیم
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
تستهای UI در Compose از معناشناسی برای تعامل با سلسله مراتب UI استفاده میکنند. Semantics، همانطور که از نام آن پیداست، به یک قطعه از UI معنی می دهد. در این زمینه، یک "تکه از UI" (یا عنصر) می تواند به معنای هر چیزی باشد، از یک ترکیب پذیر تا یک صفحه کامل. درخت معناشناسی در کنار سلسله مراتب UI تولید می شود و سلسله مراتب را توصیف می کند.
میتوانید در Semantics in Compose درباره معناشناسی بیشتر بیاموزید.

شکل 1. یک سلسله مراتب رابط کاربری معمولی و درخت معنایی آن.
چارچوب معنایی عمدتاً برای دسترسی استفاده میشود، بنابراین آزمونها از اطلاعاتی که توسط معناشناسی در مورد سلسلهمراتب UI در معرض دید قرار میگیرد، استفاده میکنند. توسعهدهندگان تصمیم میگیرند چه چیزی و چه مقدار را در معرض دید قرار دهند.

شکل 2. یک دکمه معمولی حاوی نماد و متن.
برای مثال، با توجه به دکمهای مانند این که از یک نماد و یک عنصر متنی تشکیل شده است، درخت معنایی پیشفرض فقط حاوی برچسب متنی "Like" است. این به این دلیل است که برخی از ترکیبپذیرها، مانند Text
، برخی از ویژگیها را در معرض درخت معنایی قرار میدهند. با استفاده از Modifier
میتوانید ویژگیها را به درخت معناشناسی اضافه کنید.
MyButton(
modifier = Modifier.semantics { contentDescription = "Add to favorites" }
)
منابع اضافی
- آزمایش برنامه ها در اندروید : صفحه اصلی آزمایش اندروید نمای وسیع تری از اصول و تکنیک های آزمایش ارائه می دهد.
- اصول آزمایش : درباره مفاهیم اصلی آزمایش یک برنامه اندروید بیشتر بدانید.
- تست های محلی : می توانید برخی از آزمایش ها را به صورت محلی، در ایستگاه کاری خود اجرا کنید.
- تستهای ابزاری : اجرای تستهای ابزاری نیز تمرین خوبی است. یعنی تست هایی که مستقیماً روی دستگاه اجرا می شوند.
- ادغام مداوم : ادغام مداوم به شما امکان می دهد آزمایشات خود را در خط لوله استقرار خود ادغام کنید.
- اندازههای مختلف صفحه نمایش را آزمایش کنید : با دستگاههای زیادی که در دسترس کاربران است، باید اندازههای مختلف صفحه نمایش را آزمایش کنید.
- اسپرسو : در حالی که برای UI های مبتنی بر View در نظر گرفته شده است، دانش اسپرسو همچنان می تواند برای برخی از جنبه های تست Compose مفید باشد.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Semantics\n\nUI tests in Compose use *semantics* to interact with the UI hierarchy.\nSemantics, as the name implies, give meaning to a piece of UI. In this context,\na \"piece of UI\" (or element) can mean anything from a single composable to a\nfull screen. The *semantics tree* is generated alongside the UI hierarchy and\ndescribes the hierarchy.\n\nYou can learn more about semantics generally in [Semantics in Compose](/develop/ui/compose/accessibility/semantics).\n\n**Figure 1.** A typical UI hierarchy and its semantics tree.\n\nThe semantics framework is primarily used for accessibility, so tests take\nadvantage of the information exposed by semantics about the UI hierarchy.\nDevelopers decide what and how much to expose.\n\n**Figure 2.** A typical button containing an icon and text.\n\nFor example, given a button like this that consists of an icon and a text\nelement, the default semantics tree only contains the text label \"Like\". This is\nbecause some composables, such as `Text`, already expose some properties to the\nsemantics tree. You can add properties to the semantics tree by using a\n`Modifier`. \n\n MyButton(\n modifier = Modifier.semantics { contentDescription = \"Add to favorites\" }\n )\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."]]