시맨틱스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Compose의 UI 테스트는 시맨틱을 사용하여 UI 계층 구조와 상호작용합니다.
이름에서 알 수 있듯이 시맨틱은 UI 요소에 의미를 부여합니다. 이 컨텍스트에서 'UI 조각' (또는 요소)은 단일 컴포저블에서 전체 화면에 이르기까지의 어떤 것을 의미할 수 있습니다. 시맨틱 트리는 UI 계층 구조와 함께 생성되고 계층 구조를 설명합니다.
일반적인 시맨틱에 관한 자세한 내용은 Compose의 시맨틱을 참고하세요.
그림 1. 일반적인 UI 계층 구조 및 시맨틱 트리
시맨틱 프레임워크는 주로 접근성에 사용되므로 테스트는 시맨틱에 의해 노출되는 UI 계층 구조 관련 정보를 활용합니다.
개발자는 노출할 내용과 양을 결정합니다.
그림 2. 아이콘 및 텍스트가 포함된 일반적인 버튼
예를 들어 아이콘과 텍스트 요소로 구성된 이 같은 버튼의 경우 기본 시맨틱 트리에는 '좋아요'라는 텍스트 라벨만 포함됩니다. Text
와 같은 일부 컴포저블이 일부 속성을 이미 시맨틱 트리에 노출하기 때문입니다. Modifier
를 사용하여 시맨틱 트리에 속성을 추가할 수 있습니다.
MyButton(
modifier = Modifier.semantics { contentDescription = "Add to favorites" }
)
추가 리소스
- Android에서 앱 테스트: Android 테스트 기본사항 및 기법에 관한 광범위한 정보를 제공하는 기본 Android 테스트 방문 페이지입니다.
- 테스트 기본사항: Android 앱 테스트의 핵심 개념을 자세히 알아봅니다.
- 로컬 테스트: 일부 테스트는 자체 워크스테이션에서 로컬로 실행할 수 있습니다.
- 계측 테스트: 계측 테스트도 실행하는 것이 좋습니다. 즉, 기기에서 직접 실행되는 테스트입니다.
- 지속적 통합:
지속적 통합을 사용하면 테스트를 배포 파이프라인에 통합할 수 있습니다.
- 다양한 화면 크기 테스트: 사용자가 사용할 수 있는 기기가 많으므로 다양한 화면 크기를 테스트해야 합니다.
- Espresso: Espresso는 뷰 기반 UI를 위한 것이지만 Compose 테스트의 일부 측면에서는 여전히 유용할 수 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-21(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-21(UTC)"],[],[],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."]]