앱의 UI를 테스트하여 Compose 코드의 동작이 올바른지 확인합니다. 이를 통해 오류를 조기에 발견하고 앱 품질을 개선할 수 있습니다.
Compose는 요소를 찾고 요소의 속성을 확인하며 사용자 작업을 실행하는 일련의 테스트 API를 제공합니다. API에는 시간 조작과 같은 고급 기능도 포함되어 있습니다. 이러한 API를 사용하여 앱의 동작을 확인하는 강력한 테스트를 만드세요.
뷰
Compose 대신 뷰를 사용하는 경우 일반적인 Android에서 앱 테스트 섹션을 참고하세요.
특히 UI 테스트 자동화 가이드부터 시작하는 것이 좋습니다. 뷰를 사용할 때를 포함하여 기기에서 실행되는 테스트를 자동화할 수 있는 방법을 설명합니다.
주요 개념
다음은 Compose 코드를 테스트하기 위한 몇 가지 주요 개념입니다.
- 시맨틱: Compose 테스트는 UI의 일부에 의미를 부여하고 UI 계층 구조와 함께 생성되는 시맨틱을 사용하여 UI와 상호작용합니다.
- API 테스트: Compose는 요소를 찾고, 요소의 상태와 속성에 관한 어설션을 만들고, 사용자 상호작용을 시뮬레이션하는 작업을 실행하기 위한 테스트 API를 제공합니다.
- 동기화: 기본적으로 Compose 테스트는 UI와 자동으로 동기화되며 어설션을 만들거나 작업을 실행하기 전에 유휴 상태가 될 때까지 기다립니다.
- 상호 운용성: 하이브리드 앱에서 테스트는 Compose 및 뷰 기반 요소와 원활하게 상호작용하고 다른 테스트 프레임워크와 통합할 수 있습니다.
테스트 요약본
Compose에서 테스트에 관해 알아야 하는 모든 주요 주제에 관한 개요는 테스트 요약본을 참고하세요.
설정
Compose 코드를 테스트할 수 있도록 앱을 설정합니다.
먼저, UI 테스트가 포함된 모듈의 build.gradle
파일에 다음 종속 항목을 추가합니다.
// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")
// Needed for createComposeRule(), but not for createAndroidComposeRule<YourActivity>():
debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
이 모듈에는 ComposeTestRule
과 Android용 구현인 AndroidComposeTestRule
가 포함되어 있습니다. 이 규칙을 통해 Compose 콘텐츠를 설정하거나 활동에 액세스할 수 있습니다. 팩토리 함수(createComposeRule
또는 활동에 액세스해야 하는 경우 createAndroidComposeRule
)를 사용하여 규칙을 구성합니다. Compose의 일반적인 UI 테스트는 다음과 같습니다.
// file: app/src/androidTest/java/com/package/MyComposeTest.kt
class MyComposeTest {
@get:Rule val composeTestRule = createComposeRule()
// use createAndroidComposeRule<YourActivity>() if you need access to
// an activity
@Test
fun myTest() {
// Start the app
composeTestRule.setContent {
MyAppTheme {
MainScreen(uiState = fakeUiState, /*...*/)
}
}
composeTestRule.onNodeWithText("Continue").performClick()
composeTestRule.onNodeWithText("Welcome").assertIsDisplayed()
}
}
추가 리소스
- Android에서 앱 테스트: 기본 Android 테스트 방문 페이지에서는 테스트의 기본사항 및 기법을 폭넓게 살펴볼 수 있습니다.
- 테스트 기본 요소: Android 앱 테스트의 핵심 개념을 자세히 알아보세요.
- 로컬 테스트: 일부 테스트는 자체 워크스테이션에서 로컬로 실행할 수 있습니다.
- 계측 테스트: 계측 테스트도 실행하는 것이 좋습니다. 즉, 기기에서 직접 실행되는 테스트입니다.
- 지속적 통합: 지속적 통합을 사용하면 테스트를 배포 파이프라인에 통합할 수 있습니다.
- 다양한 화면 크기 테스트: 사용자가 사용할 수 있는 기기가 많으므로 다양한 화면 크기를 테스트해야 합니다.
- Espresso: 뷰 기반 UI를 위한 것이지만 Espresso 지식은 여전히 Compose 테스트의 일부 측면에 유용할 수 있습니다.
Codelab
자세한 내용은 Jetpack Compose 테스트 Codelab을 참고하세요.
샘플
Android 16 베타 2가 출시되었습니다. 하이브리드 자동 노출, 정밀한 색상 조정, 울트라 HDR 이미지 업데이트, 새로운 AGSL 효과 등 전문가급의 카메라 기능이 지원됩니다. 최신 동작 변경사항을 꼭 테스트해 보세요. 2024년 Google Play 및 Android 앱 생태계를 안전하게 보호한 방법 Google은 생태계를 보호하기 위한 다양한 방법에 계속 투자하고 있으며, Google Play를 안전하게 유지하는 것이 최우선 과제입니다. 2024년이 저물고 있습니다. 그동안 파트너십을 맺고 협력해 주셔서 진심으로 감사드립니다. 지난 한 해 커뮤니티에 중요한 역할을 해주신 점 Google Play팀을 대신해 진심으로 감사드립니다. Android 16의 첫 번째 개발자 프리뷰: Android 16 개발자 프리뷰 1이 출시되었으며 현재 앱에서 테스트할 수 있습니다. Google Play에서 비즈니스 성공을 거두기 위한 최신 업데이트: 앱 및 게임과 관련된 최신 업데이트를 통해, 잠재고객과 사용자 참여를 늘리고 수익을 최적화하세요. #TheAndroidShow에서 Made by Google 발표: 새로운 Pixel 폴더블과 스마트워치 등 이번 달 Made by Google 이벤트의 다양한 혜택을 확인하세요. 그런 다음 Wear OS 5, 폴더블 등에 맞게 빌드하는 방법을 간단히 살펴보세요. 콘텐츠를 위한 새로운 기기 내 표시 경로인 컬렉션 소개: 컬렉션은 시청 또는 듣기와 같은 의도 중심의 공간에서 사용자에게 설치된 앱에서 가장 관련성이 높은 최적의 콘텐츠를 제공합니다. Android 15 released to AOSP: now released to the Android Open Source Project (AOSP), Android 15 continues our focus on a private and secure platform that helps improve your productivity. Top updates from Google Play at I/O: discover new ways to reach the right audiences with the right content, boost your revenue with more payment options, and build safer app experiences. Google Play at I/O 2024: check out the Google Play keynote to discover the latest helpful products and features. Google I/O program details are now live: Get a sneak peek at this year’s 150+ sessions and learning content covering mobile, web, multi-platform development, and more. Play is back at Google I/O: Join us online on May 14 to discover, innovate, and unlock new possibilities with Google's latest developer tools. The first developer preview of Android 15 is here: Android 15 makes it easier to improve your productivity with enhancements to performance, privacy, security, and user expression. Google for Games Developer Summit returns March 12: hear from teams across Google on the latest products and best practices to drive business growth across the entire game lifecycle. Since joining Google Play at the start of this year, it's been my privilege to support the hard work and creativity of our incredible community of people building apps and games. 5 must-know Google Play updates: discover new ways to grow and engage your audience, create best-in-class experiences, and monetize your apps and games on Google Play. Learn how we're supporting app quality on Google Play: we're rolling out updates across generative AI, photo and video permissions, and more - all designed to protect users. Learn more about the changes we're making to keep Google Play safe for developers and users. Notes from Google Play: Keeping our platform safe - people are increasingly concerned about the privacy and security of the titles they download. Therefore, it’s more important than ever to grow user trust with high-quality app experiences built on a secure foundation. Get help from Google AI when drafting your custom store listing - take our new Google Play Academy course to learn how an experimental Google AI feature can help you draft custom store listings. A new Play Store for large screens - this new version helps users more easily find high-quality apps and games that are optimized for their tablets, foldables, and Chromebooks. New price experiments feature now available in Play Console - price your in-app products with confidence with our new price experiments feature. In just minutes, set up a test to optimize for local purchasing power across markets. Google Play at I/O 2023 - over the past year, our teams have been laser-focused on building exciting new features and making major changes to help your business thrive on Google Play. Giving users control over account data - apps that allow account creation will soon need to allow users to initiate account and data deletion from within the app and online. Showcase your apps' privacy and security practices in your Data safety section in a simple and easy-to-understand way. Let’s go, it’s Google I/O - join us online on May 10. Learn about the latest Google Play updates at Google I/O and what we’re doing to help you work smarter, ship faster, and stay inspired.2025년 2월
2025년 1월
2024년 12월
2024년 11월
2024년 10월
2024년 8월
2024년 7월
September 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
현재 추천 자료가 없습니다.
Google 계정에 로그인해 보세요.