{"id":44348,"date":"2020-06-27T23:10:53","date_gmt":"2020-06-27T14:10:53","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=44348"},"modified":"2020-06-27T23:10:53","modified_gmt":"2020-06-27T14:10:53","slug":"hilt-6-3-testing-instrumentation-testing","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=44348","title":{"rendered":"[Hilt] 6.3 Testing &#8211; Instrumentation Testing"},"content":{"rendered":"<p><a href=\"https:\/\/dagger.dev\/hilt\/instrumentation-testing\">https:\/\/dagger.dev\/hilt\/instrumentation-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.3 Testing &#8211; Instrumentation 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>\uc548\ub4dc\ub85c\uc774\ub4dc Instrumentation \ud14c\uc2a4\ud2b8\uc5d0\uc11c AndroidJUnitRunner\ub97c \ud655\uc7a5\ud558\ub294 \uc0ac\uc6a9\uc790\ud654 \ud14c\uc2a4\ud2b8 \ub7ec\ub108(runner)\ub97c \uc0ac\uc6a9\ud558\uc5ec Application\uc774 \uc124\uc815\ub420 \uc218 \uc788\ub2e4. \ub7ec\ub108\ub97c \uc0ac\uc6a9\ud558\ub294 Application\uc744 \uc124\uc815\ud558\uae30 \uc704\ud574\uc11c newApplication \uba54\uc11c\ub4dc\ub97c \uc7ac\uc815\uc758 \ud558\uace0 Application \ud074\ub798\uc2a4 \uc774\ub984\uc744 \ub118\uae30\uba74 \ub41c\ub2e4. Hilt \ud14c\uc2a4\ud2b8\uc5d0\uc11c\ub294 Application\uc740 \ubc18\ub4dc\uc2dc HiltTestApplication \ub610\ub294 \uc0ac\uc6a9\uc790\ud654 \ud14c\uc2a4\ud2b8 Application \uc911 \ud558\ub098\uac00 \ub418\uc5b4\uc57c \ud55c\ub2e4.<\/p>\n<pre><code class=\"language-kotlin\">package my.pkg\r\n\r\nclass MyTestRunner extends AndroidJUnitRunner {\r\n  override fun newApplication(\r\n      cl: ClassLoader,\r\n      appName: String,\r\n      context: Context) : Application {\r\n    return super.newApplication(\r\n        cl, HiltTestApplication::class.java.getName(), context)\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>\ucd94\uac00\uc801\uc73c\ub85c \uc8fc\uc5b4\uc9c4 Gradle \ubaa8\ub4c8\uc5d0 \ub300\ud55c testInstrumentationRunner\ub294 \ubc18\ub4dc\uc2dc build.gradle \ud30c\uc77c\uc5d0\uc11c \uc124\uc815\ub418\uc5b4\uc57c \ud55c\ub2e4.<\/p>\n<pre class=\"\"><code class=\"language-groovy\">android {\r\n    defaultConfig {\r\n        testInstrumentationRunner \"my.pkg.MyTestRunner\"\r\n    }\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/dagger.dev\/hilt\/instrumentation-testing 6.3 Testing &#8211; Instrumentation 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. \uc548\ub4dc\ub85c\uc774\ub4dc Instrumentation \ud14c\uc2a4\ud2b8\uc5d0\uc11c AndroidJUnitRunner\ub97c \ud655\uc7a5\ud558\ub294 \uc0ac\uc6a9\uc790\ud654 \ud14c\uc2a4\ud2b8 \ub7ec\ub108(runner)\ub97c \uc0ac\uc6a9\ud558\uc5ec Application\uc774 \uc124\uc815\ub420 \uc218 \uc788\ub2e4. \ub7ec\ub108\ub97c \uc0ac\uc6a9\ud558\ub294 Application\uc744 [&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\/44348"}],"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=44348"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/44348\/revisions"}],"predecessor-version":[{"id":44349,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/44348\/revisions\/44349"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}