{"id":45790,"date":"2021-11-24T15:50:48","date_gmt":"2021-11-24T06:50:48","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=45790"},"modified":"2021-11-24T15:50:50","modified_gmt":"2021-11-24T06:50:50","slug":"migrating-to-jetpack-compose-%ed%85%8c%ec%8a%a4%ed%8a%b8-%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=45790","title":{"rendered":"Migrating to Jetpack Compose &#8211; \ud14c\uc2a4\ud2b8 \ud558\uae30"},"content":{"rendered":"\n<p>\uc2dd\ubb3c \uc138\ubd80 \uc815\ubcf4 \ud654\uba74\uc758 \uc77c\ubd80\ub97c \ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\ud55c \ud6c4, \uc544\ubb34 \uac83\ub3c4 \uc190\uc0c1\ub418\uc9c0 \uc54a\uc558\ub294\uc9c0 \ud14c\uc2a4\ud2b8\ud558\ub294 \uac83\uc774 \uc911\uc694\ud558\ub2e4.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><strong>Note<\/strong>: \uc2e4\uc81c \uc571\uc5d0\uc11c\ub294 \ud14c\uc2a4\ud2b8 \uc5c6\uc774 \ub808\uac70\uc2dc \ucf54\ub4dc\ub97c \ub2e4\uc2dc \uc791\uc131\ud574\uc11c\ub294 \uc548\ub41c\ub2e4. \ub610\ud55c \ucf54\ub4dc\ub97c \ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\ud558\ub294 \ub3d9\uc548 \ud14c\uc2a4\ud2b8\ub97c \ub9ac\ud329\ud1a0\ub9c1\ud558\uace0 \ud328\uc2a4(\ub179\uc0c9) \ud560\uc218 \uc788\ub3c4\ub85d \uc720\uc9c0\ud574\uc57c \ud55c\ub2e4.<\/p><\/blockquote>\n\n\n\n<p>Sunflower\uc5d0\uc11c androidTest \ud3f4\ub354\uc5d0 \uc788\ub294 PlantDetailFragmentTest\ub294 \uc571\uc758 \uc77c\ubd80 \uae30\ub2a5\uc744 \ud14c\uc2a4\ud2b8\ud55c\ub2e4. \ud30c\uc77c\uc744 \uc5f4\uace0 \ud604\uc7ac \ucf54\ub4dc\ub97c \uc0b4\ud3b4\ubcf4\uc790.<\/p>\n\n\n\n<ul><li>testPlantName\uc740 \ud654\uba74\uc0c1\uc758 \uc2dd\ubb3c\uc774\ub984\uc744 \ud655\uc778\ud55c\ub2e4.<\/li><li>testShareTextIntent\ub294 \uacf5\uc720 \ubc84\ud2bc\uc744 \ud0ed\ud55c \ud6c4\uc5d0 \uc62c\ubc14\ub978 \uc758\ub3c4\uac00 \ud2b8\ub9ac\uac70 \ub418\ub294\uc9c0 \ud655\uc778\ud55c\ub2e4.<\/li><\/ul>\n\n\n\n<p>\uc561\ud2f0\ube44\ud2f0 \ub610\ub294 \ud504\ub798\uadf8\uba3c\ud2b8\uac00 \ucef4\ud3ec\uc988\ub97c \uc0ac\uc6a9\ud558\ub294 \uacbd\uc6b0 ActivityScenarioRule\uc744 \uc0ac\uc6a9\ud558\ub294 \ub300\uc2e0 Compose \ucf54\ub4dc\ub97c \ud14c\uc2a4\ud2b8\ud560 \uc218 \uc788\ub294 ComposeTestRule\uacfc ActivityScenarioRule\uc744 \ud1b5\ud569\ud558\ub294 <a href=\"https:\/\/developer.android.com\/reference\/kotlin\/androidx\/compose\/ui\/test\/junit4\/package-summary#createAndroidComposeRule()\">createAndroidComposeRule<\/a>\uc744 \uc0ac\uc6a9\ud574\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<p>PlantDetailFragmentTest\uc5d0\uc11c ActivityScenarioRule \uc0ac\uc6a9\uc744 createAndroidComposeRule\ub85c \ubc14\uafbc\ub2e4. \ud14c\uc2a4\ud2b8\ub97c \uad6c\uc131\ud558\ub294 \ub370 \uc561\ud2f0\ube44\ud2f0 rule\uc774 \ud544\uc694\ud55c \uacbd\uc6b0 \ub2e4\uc74c\uacfc \uac19\uc774 createAndroidComposeRule\uc758 activityRule \uc18d\uc131\uc744 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@RunWith(AndroidJUnit4::class)<br>class PlantDetailFragmentTest {<br><br>&nbsp; &nbsp; @Rule<br>&nbsp; &nbsp; @JvmField<br>&nbsp; &nbsp; val composeTestRule = createAndroidComposeRule&lt;GardenActivity&gt;()<br>&nbsp; &nbsp;<br>&nbsp; &nbsp; ...<br><br>&nbsp; &nbsp; @Before<br>&nbsp; &nbsp; fun jumpToPlantDetailFragment() {<br>&nbsp; &nbsp; &nbsp; &nbsp; populateDatabase()<br><br>&nbsp; &nbsp; &nbsp; &nbsp; composeTestRule.activityRule.scenario.onActivity { gardenActivity -&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; activity = gardenActivity<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val bundle = Bundle().apply { putString(\"plantId\", \"malus-pumila\") }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; findNavController(activity, R.id.nav_host).navigate(R.id.plant_detail_fragment, bundle)<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp; ...<br>}<\/code><\/pre>\n\n\n\n<p>\ud14c\uc2a4\ud2b8\ub97c \uc2e4\ud589\ud558\uba74 testPlantName\uc774 \uc2e4\ud328\ud55c\ub2e4! testPlantName\uc740 TextView\uac00 \ud654\uba74\uc5d0 \ud45c\uc2dc\ub418\ub294\uc9c0 \ud655\uc778\ud55c\ub2e4. \uadf8\ub7ec\ub098 UI\uc758 \ud574\ub2f9 \ubd80\ubd84\uc744 \ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158 \ud588\ub2e4. \ub530\ub77c\uc11c \ub300\uc2e0 \ucef4\ud3ec\uc988 assertion\uc744 \uc0ac\uc6a9\ud574\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test<br>fun testPlantName() {<br>&nbsp; &nbsp; composeTestRule.onNodeWithText(\"Apple\").assertIsDisplayed()<br>}<\/code><\/pre>\n\n\n\n<p>\ud14c\uc2a4\ud2b8\ub97c \uc2e4\ud589\ud558\uba74, \ubaa8\ub450 \ud1b5\uacfc\ud558\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-migration\/img\/284a1c1cffbe911b.png\" alt=\"284a1c1cffbe911b.png\"\/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\uc2dd\ubb3c \uc138\ubd80 \uc815\ubcf4 \ud654\uba74\uc758 \uc77c\ubd80\ub97c \ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\ud55c \ud6c4, \uc544\ubb34 \uac83\ub3c4 \uc190\uc0c1\ub418\uc9c0 \uc54a\uc558\ub294\uc9c0 \ud14c\uc2a4\ud2b8\ud558\ub294 \uac83\uc774 \uc911\uc694\ud558\ub2e4. Note: \uc2e4\uc81c \uc571\uc5d0\uc11c\ub294 \ud14c\uc2a4\ud2b8 \uc5c6\uc774 \ub808\uac70\uc2dc \ucf54\ub4dc\ub97c \ub2e4\uc2dc \uc791\uc131\ud574\uc11c\ub294 \uc548\ub41c\ub2e4. \ub610\ud55c \ucf54\ub4dc\ub97c \ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\ud558\ub294 \ub3d9\uc548 \ud14c\uc2a4\ud2b8\ub97c \ub9ac\ud329\ud1a0\ub9c1\ud558\uace0 \ud328\uc2a4(\ub179\uc0c9) \ud560\uc218 \uc788\ub3c4\ub85d \uc720\uc9c0\ud574\uc57c \ud55c\ub2e4. Sunflower\uc5d0\uc11c androidTest \ud3f4\ub354\uc5d0 \uc788\ub294 PlantDetailFragmentTest\ub294 \uc571\uc758 \uc77c\ubd80 \uae30\ub2a5\uc744 \ud14c\uc2a4\ud2b8\ud55c\ub2e4. \ud30c\uc77c\uc744 \uc5f4\uace0 \ud604\uc7ac \ucf54\ub4dc\ub97c [&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\/45790"}],"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=45790"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45790\/revisions"}],"predecessor-version":[{"id":45791,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45790\/revisions\/45791"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}