{"id":45764,"date":"2021-11-23T18:02:57","date_gmt":"2021-11-23T09:02:57","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=45764"},"modified":"2021-11-23T18:02:59","modified_gmt":"2021-11-23T09:02:59","slug":"testing-in-jetpack-compose-%eb%8f%99%ea%b8%b0%ed%99%94","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=45764","title":{"rendered":"Testing in Jetpack Compose &#8211; \ub3d9\uae30\ud654"},"content":{"rendered":"\n<p>\uc791\uc131\ud558\ub294 \ubaa8\ub4e0 \ud14c\uc2a4\ud2b8\ub294 \ud14c\uc2a4\ud2b8 \ub300\uc0c1\uacfc \uc801\uc808\ud558\uac8c \ub3d9\uae30\ud654(synchronization)\ub418\uc5b4\uc57c \ud55c\ub2e4. \uc608\ub97c \ub4e4\uc5b4 onNodeWithText\uc640 \uac19\uc740 finder\ub97c \uc0ac\uc6a9\ud560 \ub54c, \ud14c\uc2a4\ud2b8\ub294 \uc2dc\ub9e8\ud2f1 \ud2b8\ub9ac\ub97c \ucffc\ub9ac\ud558\uae30 \uc804\uc5d0 \uc571\uc774 \uc720\ud734 \uc0c1\ud0dc\uac00 \ub420 \ub54c\uae4c\uc9c0 \uae30\ub2e4\ub9b0\ub2e4. \ub3d9\uae30\ud654\uac00 \uc5c6\uc73c\uba74 \ud14c\uc2a4\ud2b8\uc5d0\uc11c \ud45c\uc2dc\ub418\uae30 \uc804\uc5d0 \uc694\uc18c\ub97c \ucc3e\uac70\ub098 \ubd88\ud544\uc694\ud558\uac8c \uae30\ub2e4\ub9b4 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p>\uc774 \ub2e8\uacc4\uc5d0\uc11c\ub294 \uc571\uc744 \uc2e4\ud589\ud560 \ub54c \ub2e4\uc74c\uacfc \uac19\uc740 Overview(\uac1c\uc694) \ud654\uba74\uc744 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-testing\/img\/17e585f529a6d613.gif?hl=ko\" alt=\"17e585f529a6d613.gif\" width=\"400\" height=\"711\"\/><\/figure>\n\n\n\n<p>&#8216;Alerts&#8217; \uce74\ub4dc\uc758 \ubc18\ubcf5\uc801\uc778 \uae5c\ubc15\uc784 \uc560\ub2c8\uba54\uc774\uc158\uc5d0 \uc8fc\ubaa9\ud558\uace0, \uc774 \uc694\uc18c\uc5d0 \uc8fc\uc758\ub97c \uae30\uc6b8\uc774\uc790.<\/p>\n\n\n\n<p>OverviewScreenTest\ub77c\ub294 \ub2e4\ub978 \ud14c\uc2a4\ud2b8 \ud074\ub798\uc2a4\ub97c \ub9cc\ub4e4\uace0, \ub2e4\uc74c \ub0b4\uc6a9\uc744 \ucd94\uac00\ud558\uc790.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class OverviewScreenTest {<br><br>&nbsp; &nbsp; @get:Rule<br>&nbsp; &nbsp; val composeTestRule = createComposeRule()<br><br>&nbsp; &nbsp; @Test<br>&nbsp; &nbsp; fun overviewScreen_alertsDisplayed() {<br>&nbsp; &nbsp; &nbsp; &nbsp; composeTestRule.setContent {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OverviewBody()<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; composeTestRule<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .onNodeWithText(\"Alerts\")<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .assertIsDisplayed()<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>\ub9cc\uc57d \ud14c\uc2a4\ud2b8\ub97c \uc2e4\ud589\ud558\uba74, \ud14c\uc2a4\ud2b8\uac00 \ub05d\ub098\uc9c0 \uc54a\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4. (30\ucd08 \ud6c4\uc5d0 \ud0c0\uc784\uc544\uc6c3 \ub41c\ub2e4)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-testing\/img\/880d5515b578d45e.png?hl=ko\" alt=\"880d5515b578d45e.png\"\/><\/figure>\n\n\n\n<p>\uc5d0\ub7ec \ub0b4\uc6a9\uc740 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>androidx.compose.ui.test.junit4.android.ComposeNotIdleException: Idling resource timed out: possibly due to compose being busy.<br>IdlingResourceRegistry has the following idling resources registered:<br>- &#91;busy] androidx.compose.ui.test.junit4.android.ComposeIdlingResource@d075f91 <\/code><\/pre>\n\n\n\n<p>\uc774\uac83\uc740 \uae30\ubcf8\uc801\uc73c\ub85c \ucef4\ud3ec\uc988\uac00 \uc9c0\uc18d\uc801\uc73c\ub85c \ubb34\uc5b8\uac00 \ud558\uae30 \ub54c\ubb38\uc5d0(busy), \uc571\uc744 \ud14c\uc2a4\ud2b8\uc640 \ub3d9\uae30\ud654]\ud560 \ubc29\ubc95\uc774 \uc5c6\ub2e4\ub294 \uac83\uc744 \uc54c\ub824\uc900\ub2e4.<\/p>\n\n\n\n<p>\uc774\ubbf8 \uc9d0\uc791\ud588\uc744 \uac83\uc774\ub2e4. \ubb38\uc81c\ub294 \ubb34\ud55c\uc73c\ub85c \uae5c\ubc15\uc774\ub294 \uc560\ub2c8\uba54\uc774\uc158\uc774\ub2e4. \uc571\uc774 \uc720\ud734(idle) \uc0c1\ud0dc\uac00 \uc544\ub2c8\ubbc0\ub85c \ud14c\uc2a4\ud2b8\ub97c \uacc4\uc18d\ud560 \uc218 \uc5c6\ub2e4.<\/p>\n\n\n\n<p>\ubb34\ud55c \uc560\ub2c8\uba54\uc774\uc158\uc758 \uad6c\ud604\uc744 \uc0b4\ud3b4\ubcf4\uc790.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">app\/src\/main\/java\/com\/example\/compose\/rally\/ui\/overview\/OverviewScreen.kt<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>var currentTargetElevation by remember { &nbsp;mutableStateOf(1.dp) }<br>LaunchedEffect(Unit) {<br>&nbsp; &nbsp; \/\/ Start the animation<br>&nbsp; &nbsp; currentTargetElevation = 8.dp<br>}<br>val animatedElevation = animateDpAsState(<br>&nbsp; &nbsp; targetValue = currentTargetElevation,<br>&nbsp; &nbsp; animationSpec = tween(durationMillis = 500),<br>&nbsp; &nbsp; finishedListener = {<br>&nbsp; &nbsp; &nbsp; &nbsp; currentTargetElevation = if (currentTargetElevation &gt; 4.dp) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.dp<br>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8.dp<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>)<br>Card(elevation = animatedElevation.value) { ... }<\/code><\/pre>\n\n\n\n<p>\uc774 \ucf54\ub4dc\ub294 \uae30\ubcf8\uc801\uc73c\ub85c \uc560\ub2c8\uba54\uc774\uc158\uc774 \uc644\ub8cc\ub418\uae30\ub97c \uae30\ub2e4\ub9ac\uace0(finishedListener) \ub2e4\uc2dc \uc2e4\ud589\ud55c\ub2e4.<\/p>\n\n\n\n<p>\uc774 \ud14c\uc2a4\ud2b8\ub97c \uc218\uc815\ud558\ub294 \ud55c \uac00\uc9c0 \ubc29\ubc95\uc740 \uac1c\ubc1c\uc790 \uc635\uc158\uc5d0\uc11c \uc560\ub2c8\uba54\uc774\uc158\uc744 \ube44\ud65c\uc131\ud654\ud558\ub294 \uac83\uc774\ub2e4. \uc774\ub294 View \uc2dc\uc2a4\ud15c\uc5d0\uc11c \uc774\ub97c \ucc98\ub9ac\ud558\ub294 \ub110\ub9ac \ud5c8\uc6a9\ub418\ub294 \ubc29\ubc95 \uc911 \ud558\ub098\ub2e4.<\/p>\n\n\n\n<p>\ucef4\ud3ec\uc988\uc5d0\uc11c \uc560\ub2c8\uba54\uc774\uc158 API\ub294 \ud14c\uc2a4\ud2b8 \uac00\ub2a5\uc131\uc744 \uc5fc\ub450\uc5d0 \ub450\uace0 \uc124\uacc4\ub418\uc5c8\uc73c\ubbc0\ub85c, \uc62c\ubc14\ub978 API\ub97c \uc0ac\uc6a9\ud558\uc5ec \ubb38\uc81c\ub97c \ud574\uacb0\ud560 \uc218 \uc788\ub2e4. animateDpAsState \uc560\ub2c8\uba54\uc774\uc158\uc744 \ub2e4\uc2dc \uc2dc\uc791\ud558\ub294 \ub300\uc2e0, <a href=\"https:\/\/developer.android.com\/jetpack\/compose\/animation?hl=ko#rememberinfinitetransition\">\ubb34\ud55c \uc560\ub2c8\uba54\uc774\uc158<\/a>\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\ubb34\ud55c \uc560\ub2c8\uba54\uc774\uc158\uc740 \ucef4\ud3ec\uc988\uac00\ud14c\uc2a4\ud2b8\uac00 \uc774\ud574\ud558\ub294 \ud2b9\ubcc4\ud55c \uacbd\uc6b0\uc774\ubbc0\ub85c, \ud14c\uc2a4\ud2b8\ub97c \ubc14\uc058\uac8c(busy) \uc720\uc9c0\ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p><\/blockquote>\n\n\n\n<p>OverviewScreen.kt\uc5d0\uc11c AlertCard \ucef4\ud3ec\uc800\ube14 \ud568\uc218\uc758 \ucf54\ub4dc\ub97c \uc801\uc808\ud55c API\ub85c \ubc14\uafd4\ubcf4\uc790.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp; &nbsp; val infiniteElevationAnimation = rememberInfiniteTransition()<br>&nbsp; &nbsp; val animatedElevation: Dp by infiniteElevationAnimation.animateValue(<br>&nbsp; &nbsp; &nbsp; &nbsp; initialValue = 1.dp,<br>&nbsp; &nbsp; &nbsp; &nbsp; targetValue = 8.dp,<br>&nbsp; &nbsp; &nbsp; &nbsp; typeConverter = Dp.VectorConverter,<br>&nbsp; &nbsp; &nbsp; &nbsp; animationSpec = infiniteRepeatable(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; animation = tween(500),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repeatMode = RepeatMode.Reverse<br>&nbsp; &nbsp; &nbsp; &nbsp; )<br>&nbsp; &nbsp; )<br>&nbsp; &nbsp; Card(elevation = animatedElevation) {<\/code><\/pre>\n\n\n\n<p>\ud14c\uc2a4\ud2b8\ub97c \uc2e4\ud589\ud558\uba74 \uc774\uc81c \ud1b5\uacfc\ud558\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-testing\/img\/4381509baa58644f.png?hl=ko\" alt=\"4381509baa58644f.png\"\/><\/figure>\n\n\n\n<p>\ucd95\ud558! \uc774 \ub2e8\uacc4\uc5d0\uc11c\ub294 \ub3d9\uae30\ud654\uc640 \uc560\ub2c8\uba54\uc774\uc158\uc774 \ud14c\uc2a4\ud2b8\uc5d0 \ubbf8\uce58\ub294 \uc601\ud5a5\uc5d0 \ub300\ud574 \ubc30\uc6e0\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc791\uc131\ud558\ub294 \ubaa8\ub4e0 \ud14c\uc2a4\ud2b8\ub294 \ud14c\uc2a4\ud2b8 \ub300\uc0c1\uacfc \uc801\uc808\ud558\uac8c \ub3d9\uae30\ud654(synchronization)\ub418\uc5b4\uc57c \ud55c\ub2e4. \uc608\ub97c \ub4e4\uc5b4 onNodeWithText\uc640 \uac19\uc740 finder\ub97c \uc0ac\uc6a9\ud560 \ub54c, \ud14c\uc2a4\ud2b8\ub294 \uc2dc\ub9e8\ud2f1 \ud2b8\ub9ac\ub97c \ucffc\ub9ac\ud558\uae30 \uc804\uc5d0 \uc571\uc774 \uc720\ud734 \uc0c1\ud0dc\uac00 \ub420 \ub54c\uae4c\uc9c0 \uae30\ub2e4\ub9b0\ub2e4. \ub3d9\uae30\ud654\uac00 \uc5c6\uc73c\uba74 \ud14c\uc2a4\ud2b8\uc5d0\uc11c \ud45c\uc2dc\ub418\uae30 \uc804\uc5d0 \uc694\uc18c\ub97c \ucc3e\uac70\ub098 \ubd88\ud544\uc694\ud558\uac8c \uae30\ub2e4\ub9b4 \uc218 \uc788\ub2e4. \uc774 \ub2e8\uacc4\uc5d0\uc11c\ub294 \uc571\uc744 \uc2e4\ud589\ud560 \ub54c \ub2e4\uc74c\uacfc \uac19\uc740 Overview(\uac1c\uc694) \ud654\uba74\uc744 \uc0ac\uc6a9\ud55c\ub2e4. &#8216;Alerts&#8217; \uce74\ub4dc\uc758 \ubc18\ubcf5\uc801\uc778 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[38],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45764"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45764"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45764\/revisions"}],"predecessor-version":[{"id":45765,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45764\/revisions\/45765"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}