{"id":44345,"date":"2020-06-27T23:09:00","date_gmt":"2020-06-27T14:09:00","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=44345"},"modified":"2020-06-27T23:09:41","modified_gmt":"2020-06-27T14:09:41","slug":"hilt-testing-robolectric-testing","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=44345","title":{"rendered":"[Hilt] 6.2 Testing &#8211; Robolectric Testing"},"content":{"rendered":"<p><a href=\"https:\/\/dagger.dev\/hilt\/robolectric-testing\">https:\/\/dagger.dev\/hilt\/robolectric-testing<\/a><\/p>\n<hr \/>\n<p><a href=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2020\/06\/1078edcee19384aeeaa25f053a09c82c.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2020\/06\/1078edcee19384aeeaa25f053a09c82c-236x300.png\" alt=\"\" width=\"236\" height=\"300\" class=\"aligncenter size-medium wp-image-44317\" srcset=\"https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2020\/06\/1078edcee19384aeeaa25f053a09c82c-236x300.png 236w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2020\/06\/1078edcee19384aeeaa25f053a09c82c-768x975.png 768w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2020\/06\/1078edcee19384aeeaa25f053a09c82c-807x1024.png 807w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2020\/06\/1078edcee19384aeeaa25f053a09c82c.png 1145w\" sizes=\"(max-width: 236px) 100vw, 236px\" \/><\/a><\/p>\n<h1>6.2 Testing &#8211; Robolectric Testing<\/h1>\n<h2>\ud14c\uc2a4\ud2b8 Application \uc124\uc815\ud558\uae30<\/h2>\n<p>Hilt\uc758 \ud14c\uc2a4\ud2b8 API\ub294 \ud2b9\uc815 \ud14c\uc2a4\ud2b8 \ud658\uacbd\uc5d0 \ubb34\uad00\ud558\uac8c \uc124\uacc4\ub418\uc5c8\ub2e4. \uadf8\ub7ec\ub098 \ud14c\uc2a4\ud2b8\uc5d0\uc11c Application \ud074\ub798\uc2a4\ub97c \uc124\uc815\ud558\uae30 \uc704\ud55c \ubc29\ubc95\uc740 Robolectric \ub610\ub294 \uc548\ub4dc\ub85c\uc774\ub4dc Instrumentation \ud14c\uc2a4\ud2b8\ub97c \uc0ac\uc6a9 \uc911\uc778\uc9c0 \uc5ec\ubd80\uc5d0 \ub530\ub77c \ub2e4\ub974\ub2e4.<\/p>\n<p>Robolectric \ud14c\uc2a4\ud2b8\uc5d0\uc11c\ub294 \uad6d\uc18c\uc801\uc73c\ub85c <a href=\"http:\/\/robolectric.org\/javadoc\/latest\/org\/robolectric\/annotation\/Config.html\">@Config<\/a>\ub97c \uc0ac\uc6a9\ud558\uac70\ub098 \uc804\uc5ed\uc801\uc73c\ub85c robolectric.properties\ub97c \uc0ac\uc6a9\ud558\uc5ec Application\uc744 \uc124\uc815\ud560 \uc218 \uc788\ub2e4. Hilt\ub97c \uc704\ud55c \ud14c\uc2a4\ud2b8\uc5d0\uc11c Application\uc740 \ubc18\ub4dc\uc2dc <a href=\"https:\/\/dagger.dev\/api\/latest\/dagger\/hilt\/android\/testing\/HiltTestApplication.html\">HiltTestApplication<\/a> \ub610\ub294 \uc0ac\uc6a9\uc790\ud654 \ud14c\uc2a4\ud2b8 Application \uc911 \ud558\ub098\uac00 \ub418\uc5b4\uc57c \ud55c\ub2e4.<\/p>\n<table style=\"width: 100%; border-collapse: collapse; background-color: #e6ffff;\">\n<tbody>\n<tr>\n<td style=\"width: 100%;\"><em>Note : \uc774 \uc124\uc815\uc740 Hilt\uc5d0 \ud2b9\uc815\ub418\uc9c0 \uc54a\ub294\ub2e4. <a href=\"http:\/\/robolectric.org\/configuring\/\">Robolectric \uacf5\uc2dd \ubb38\uc11c<\/a>\ub97c \ud1b5\ud574 \ub354 \ub9ce\uc740 \uc815\ubcf4\ub97c \ucc38\uc870\ud558\uc790.<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>@Config \uc0ac\uc6a9\ud558\uae30<\/h3>\n<p>Hilt\uc6a9 Application \ud074\ub798\uc2a4\ub294 \uad6d\uc18c\uc801\uc73c\ub85c @Config \uc5b4\ub178\ud14c\uc774\uc158\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc124\uc815\ub420 \uc218 \uc788\ub2e4. Application \ud074\ub798\uc2a4\ub97c \uc124\uc815\ud558\uae30 \uc704\ud574\uc11c\ub294 \ud14c\uc2a4\ud2b8 (\ub610\ub294 \ud14c\uc2a4\ud2b8 \uba54\uc11c\ub4dc)\uc5d0 @Config \uc5b4\ub178\ud14c\uc774\uc158\uc744 \ucd94\uac00\ud558\uace0 \uc5b4\ub178\ud14c\uc774\uc158\uc758 \uac12\uc73c\ub85c \uc6d0\ud558\ub294 Application \ud074\ub798\uc2a4\ub97c \uc9c0\uc815\ud558\uba74 \ub41c\ub2e4.<\/p>\n<pre><code class=\"language-kotlin\">@HiltAndroidTest\r\n@Config(application = HiltTestApplication::class)\r\nclass FooTest {...}\r\n<\/code><\/pre>\n<h3>robolectric.properties \uc0ac\uc6a9\ud558\uae30<\/h3>\n<p>Hilt \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc740 <a href=\"http:\/\/robolectric.properties\">robolectric.properties<\/a> \ud30c\uc77c\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc804\uc5ed\uc801\uc73c\ub85c \uc124\uc815\ub420 \uc218 \uc788\ub2e4. Application \ud074\ub798\uc2a4\ub97c \uc124\uc815\ud558\uae30 \uc704\ud574\uc11c\ub294 \uc801\uc815\ud55c reosurce \ud328\ud0a4\uc9c0\uc5d0 robolectric.properties \ud30c\uc77c\uc744 \uc0dd\uc131\ud558\uace0 Hilt \ud14c\uc2a4\ud2b8 Application\uc744 \uc124\uc815\ud558\uba74 \ub41c\ub2e4.<\/p>\n<pre><code>application=dagger.hilt.android.testing.HiltTestApplication\r\n<\/code><\/pre>\n<p>\uc548\ub4dc\ub85c\uc774\ub4dc Instrumentation \ud14c\uc2a4\ud2b8\uc640 \ud568\uaed8 @Config \uc5b4\ub178\ud14c\uc774\uc158\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc744 \ub54c \uc774\ub7ec\ud55c \uc811\uadfc \ubc29\uc2dd\uc744 \uc0ac\uc6a9\ud558\uba74, \ud14c\uc2a4\ud2b8\ub97c Robolectric \uadf8\ub9ac\uace0 \uc548\ub4dc\ub85c\uc774\ub4dc Instrumentation \ud658\uacbd\uc5d0\uc11c \uc2e4\ud589\ud560 \ub54c \uc720\uc6a9\ud558\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/dagger.dev\/hilt\/robolectric-testing 6.2 Testing &#8211; Robolectric Testing \ud14c\uc2a4\ud2b8 Application \uc124\uc815\ud558\uae30 Hilt\uc758 \ud14c\uc2a4\ud2b8 API\ub294 \ud2b9\uc815 \ud14c\uc2a4\ud2b8 \ud658\uacbd\uc5d0 \ubb34\uad00\ud558\uac8c \uc124\uacc4\ub418\uc5c8\ub2e4. \uadf8\ub7ec\ub098 \ud14c\uc2a4\ud2b8\uc5d0\uc11c Application \ud074\ub798\uc2a4\ub97c \uc124\uc815\ud558\uae30 \uc704\ud55c \ubc29\ubc95\uc740 Robolectric \ub610\ub294 \uc548\ub4dc\ub85c\uc774\ub4dc Instrumentation \ud14c\uc2a4\ud2b8\ub97c \uc0ac\uc6a9 \uc911\uc778\uc9c0 \uc5ec\ubd80\uc5d0 \ub530\ub77c \ub2e4\ub974\ub2e4. Robolectric \ud14c\uc2a4\ud2b8\uc5d0\uc11c\ub294 \uad6d\uc18c\uc801\uc73c\ub85c @Config\ub97c \uc0ac\uc6a9\ud558\uac70\ub098 \uc804\uc5ed\uc801\uc73c\ub85c robolectric.properties\ub97c \uc0ac\uc6a9\ud558\uc5ec Application\uc744 \uc124\uc815\ud560 \uc218 \uc788\ub2e4. Hilt\ub97c \uc704\ud55c \ud14c\uc2a4\ud2b8\uc5d0\uc11c Application\uc740 [&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":[28],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/44345"}],"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=44345"}],"version-history":[{"count":2,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/44345\/revisions"}],"predecessor-version":[{"id":44347,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/44345\/revisions\/44347"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}