Android Migrate view to compose on instrumented test

사용 버전: Android Studio Koala 2024.1.1
사용 언어: Kotlin 2.0.10


안드로이드 Migrate view to compose instrumented test를 알아보겠습니다.



먼저 View를 Compose로 변경하는 것을 알아보았고,
https://shwoghk14.blogspot.com/2024/08/android-migrate-xml-view-to-compose.html



XML themes를 compose를 변경하는 것도 알아보았습니다.




이제 대망의 Instrumented(계측) test를 view에서 compose로 변경하는 것을 알아보겠습니다.

View(뷰)의 경우 ActivityScenarioRule을 사용하게 됩니다.





이것을 우리는 AndroidComposeTestRule로 변경해야 합니다.



Test가 있는 Module(모듈)의 build.gradle.kts로 갑니다.

설명을 위해 version catalog는 일단 제외했습니다.

androidTestImplementation(platform("androidx.compose:compose-bom:2024.08.00"))

androidTestImplementation("androidx.compose.ui:ui-test-junit4")





Sync Now를 누릅니다.







TranslateFragmentTest.kt

ActivityScenario를 createAndroidComposeRule로 변경해 줍니다.






Test에는 일반 Compose에서 Test를 하듯이 composeTestRule을 사용해 주면 됩니다.






끝.


카테고리: Android

댓글

이 블로그의 인기 게시물

Python urllib.parse.quote()

Python OpenCV 빈 화면 만들기

Python bytes.fromhex()

Android AVD Ram size change

Forensics .pyc 파일 .py로 복구하기

KiCad 시작하기 2 (PCB 만들기)

About Subnet Mask App

tensorflow tf.expand_dims()

tensorflow tf.constant

Hand Counter App