{"id":277140,"date":"2016-03-29T01:32:03","date_gmt":"2016-03-28T21:32:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=277140"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=277140","title":{"rendered":"\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0432 Android \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JaCoCo"},"content":{"rendered":"<p>       \u0410\u0432\u0442\u043e\u0440: Mike Gouline<br \/>  <a href=\"https:\/\/blog.gouline.net\/2015\/06\/23\/code-coverage-on-android-with-jacoco\/\">https:\/\/blog.gouline.net\/2015\/06\/23\/code-coverage-on-android-with-jacoco\/<\/a><br \/>  \u041f\u0435\u0440\u0435\u0432\u043e\u0434: \u0421\u0435\u043c\u0451\u043d \u0421\u043e\u043b\u0434\u0430\u0442\u0435\u043d\u043a\u043e<\/p>\n<p>  \u0421 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043a\u0430\u043a \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 Android Gradle \u043f\u043b\u0430\u0433\u0438\u043d\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 0.10.0 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0431 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 (test coverage) \u2014 \u0438 \u044f \u043d\u0435 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u044e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u043b\u043b\u044e\u0437\u0438\u0439 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442, \u0442\u0430\u043a \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0434\u0430\u0436\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Gradle \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043e\u0442, \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u0441\u0431\u0435\u0440\u0435\u0447\u044c \u0432\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>  \u0418\u043c\u0435\u0435\u0442\u0441\u044f Android \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 (unit tests), \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0447\u0435\u0442 \u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0440\u0435\u0436\u0438\u043c\u044b \u0441\u0431\u043e\u0440\u043a\u0438 (build types) \u0438 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 (product flavours).<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u043e \u0448\u0430\u0433\u0430\u043c.<\/p>\n<h3>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043e\u0434\u0430<\/h3>\n<p>  \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0441\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 (build type) \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0435\u0441\u0442\u044b. \u0412\u0430\u0448 <code>build.gradle<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>android {       ...     buildTypes {         debug {             testCoverageEnabled = true         }         ...     }     ... } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 JaCoCo<\/h3>\n<p>  \u0425\u043e\u0442\u044f \u0432\u0441\u0451 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 <code>build.gradle<\/code>, \u0442\u0430\u043a\u043e\u0439 \u00ab\u043d\u0430\u0432\u0435\u0441\u043d\u043e\u0439 \u043c\u043e\u043d\u0442\u0430\u0436\u00bb \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u0431\u043e\u0440\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u041c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 JaCoCo \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 <code>jacoco.gradle<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0433\u0434\u0435 \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u0442\u0435, \u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043b\u0435\u0433\u043a\u043e \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  \u0421\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0438\u043c\u043f\u043e\u0440\u0442 JaCoCo:<\/p>\n<pre><code>apply plugin: 'jacoco'  jacoco {       toolVersion = &quot;0.7.5.201505241946&quot; } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u00abjacoco\u00bb \u2014 \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442 \u043f\u043b\u0430\u0433\u0438\u043d Android.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f, \u043f\u043e\u0438\u0449\u0438\u0442\u0435 <a href=\"https:\/\/bintray.com\/bintray\/jcenter\/org.jacoco:org.jacoco.core\">org.jacoco:org.jacoco.core<\/a> \u0432 jCenter, \u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0439\u0442\u0435 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u2014 \u0441\u0430\u043c\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0439, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043a\u0430\u043a\u0438\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044f\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a \u043f\u0443\u0441\u0442\u043e\u043c\u0443 \u043e\u0442\u0447\u0435\u0442\u0443.<\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 Gradle (Gradle tasks) \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0441\u0431\u043e\u0440\u043a\u0438 (\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 (debug), \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438).<\/p>\n<pre><code>def buildTypes = android.buildTypes.collect { type -&gt; type.name }   def productFlavors = android.productFlavors.collect { flavor -&gt; flavor.name }   <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e <code>collect<\/code> \u0432 Groovy \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0441\u043f\u0438\u0441\u043e\u043a, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0430, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 \u043d\u043e\u0432\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0441\u043f\u0438\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u00ab\u0440\u0435\u0436\u0438\u043c \u0441\u0431\u043e\u0440\u043a\u0438\u00bb \u0438 \u00ab\u0432\u0430\u0440\u0438\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u00bb \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0438 \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>  \u0412 \u0443\u0433\u043e\u0434\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0437\u0430\u0434\u0430\u043d\u044b \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0435 \u0438\u043c\u044f:<\/p>\n<pre><code>if (!productFlavors) productFlavors.add('')   <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a \u043f\u0440\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0438\u0445, \u0447\u0442\u043e \u043f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u0432 Groovy:<\/p>\n<pre><code>productFlavors.each { productFlavorName -&gt;       buildTypes.each { buildTypeName -&gt;         ...     } }  <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432\u043d\u0443\u0442\u0440\u044c \u0446\u0438\u043a\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0438\u043c\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0431\u0443\u043a\u0432:  <\/p>\n<ul>\n<li><code>sourceName<\/code> \u2013 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 (build source name), \u043d-\u0440: <code>blueDebug<\/code><\/li>\n<li><code>sourcePath<\/code> \u2013 \u043f\u0443\u0442\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u0430\u043c \u0441\u0431\u043e\u0440\u043a\u0438 (build source path), \u043d-\u0440: <code>blue\/debug<\/code><\/li>\n<li><code>testTaskName<\/code> \u2013 \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430, \u043d-\u0440: <code>testBlueDebug<\/code><\/li>\n<\/ul>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u044b \u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c:<\/p>\n<pre><code>def sourceName, sourcePath   if (!productFlavorName) {       sourceName = sourcePath = &quot;${buildTypeName}&quot; } else {     sourceName = &quot;${productFlavorName}${buildTypeName.capitalize()}&quot;     sourcePath = &quot;${productFlavorName}\/${buildTypeName}&quot; } def testTaskName = &quot;test${sourceName.capitalize()}UnitTest&quot;   <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u0430\u043a \u043e\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435:<\/p>\n<pre><code>task &quot;${testTaskName}Coverage&quot; (type:JacocoReport, dependsOn: &quot;$testTaskName&quot;) {       group = &quot;Reporting&quot;     description = &quot;Generate Jacoco coverage reports on the ${sourceName.capitalize()} build.&quot;      classDirectories = fileTree(             dir: &quot;${project.buildDir}\/intermediates\/classes\/${sourcePath}&quot;,             excludes: ['**\/R.class',                        '**\/R$*.class',                        '**\/*$ViewInjector*.*',                        '**\/BuildConfig.*',                        '**\/Manifest*.*']     )      def coverageSourceDirs = [             &quot;src\/main\/java&quot;,             &quot;src\/$productFlavorName\/java&quot;,             &quot;src\/$buildTypeName\/java&quot;     ]     additionalSourceDirs = files(coverageSourceDirs)     sourceDirectories = files(coverageSourceDirs)     executionData = files(&quot;${project.buildDir}\/jacoco\/${testTaskName}.exec&quot;)      reports {         xml.enabled = true         html.enabled = true     } } <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0433\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043a\u043e\u0434 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043f\u0440\u043e JaCoCo, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u0431\u0435\u0437 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0427\u0430\u0441\u0442\u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f:  <\/p>\n<ul>\n<li><code>classDirectories<\/code> \u2013 \u0432 <code>&quot;excludes&quot;<\/code> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0442\u0447\u0435\u0442\u0430; \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 (\u043a\u043b\u0430\u0441\u0441 <code>R<\/code>, \u043a\u043e\u0434 \u0432\u043d\u0435\u0434\u0440\u044f\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0442.\u0434.) \u0438\u043b\u0438 \u0447\u0442\u043e-\u0443\u0433\u043e\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/li>\n<li><code>reports<\/code> \u2013 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 HTML \u0438\/\u0438\u043b\u0438 XML \u043e\u0442\u0447\u0435\u0442\u044b, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u043e\u043d\u0438 \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/li>\n<\/ul>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451 \u043e <code>jacoco.gradle<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>apply plugin: 'jacoco'  jacoco {       toolVersion = &quot;0.7.5.201505241946&quot; }  project.afterEvaluate {       \/\/ Grab all build types and product flavors     def buildTypes = android.buildTypes.collect { type -&gt; type.name }     def productFlavors = android.productFlavors.collect { flavor -&gt; flavor.name }      \/\/ When no product flavors defined, use empty     if (!productFlavors) productFlavors.add('')      productFlavors.each { productFlavorName -&gt;         buildTypes.each { buildTypeName -&gt;             def sourceName, sourcePath             if (!productFlavorName) {                 sourceName = sourcePath = &quot;${buildTypeName}&quot;             } else {                 sourceName = &quot;${productFlavorName}${buildTypeName.capitalize()}&quot;                 sourcePath = &quot;${productFlavorName}\/${buildTypeName}&quot;             }             def testTaskName = &quot;test${sourceName.capitalize()}UnitTest&quot;              \/\/ Create coverage task of form 'testFlavorTypeCoverage' depending on 'testFlavorTypeUnitTest'             task &quot;${testTaskName}Coverage&quot; (type:JacocoReport, dependsOn: &quot;$testTaskName&quot;) {                 group = &quot;Reporting&quot;                 description = &quot;Generate Jacoco coverage reports on the ${sourceName.capitalize()} build.&quot;                  classDirectories = fileTree(                         dir: &quot;${project.buildDir}\/intermediates\/classes\/${sourcePath}&quot;,                         excludes: ['**\/R.class',                                    '**\/R$*.class',                                    '**\/*$ViewInjector*.*',                                    '**\/*$ViewBinder*.*',                                    '**\/BuildConfig.*',                                    '**\/Manifest*.*']                 )                  def coverageSourceDirs = [                         &quot;src\/main\/java&quot;,                         &quot;src\/$productFlavorName\/java&quot;,                         &quot;src\/$buildTypeName\/java&quot;                 ]                 additionalSourceDirs = files(coverageSourceDirs)                 sourceDirectories = files(coverageSourceDirs)                 executionData = files(&quot;${project.buildDir}\/jacoco\/${testTaskName}.exec&quot;)                  reports {                     xml.enabled = true                     html.enabled = true                 }             }         }     } } <\/code><\/pre>\n<p>  \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u0432\u0430\u0448 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432 <code>app<\/code> \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>apply from: '..\/jacoco.gradle' <\/code><\/pre>\n<p>  (\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e <code>jacoco.gradle<\/code> \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435)<\/p>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451! \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 <code>gradle tasks<\/code> \u0438 \u043f\u043e\u0438\u0441\u043a\u0430\u0432 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <code>&quot;Reporting&quot;<\/code> \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>Reporting tasks   --------------- testBlueDebugUnitTestCoverage - Generate Jacoco coverage reports on the BlueDebug build.   testBlueReleaseUnitTestCoverage - Generate Jacoco coverage reports on the BlueRelease build.   testRedDebugUnitTestCoverage - Generate Jacoco coverage reports on the RedDebug build.   testRedReleaseUnitTestCoverage - Generate Jacoco coverage reports on the RedRelease build.   <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0447\u0435\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 <code>gradle testBlueDebugUnitTestCoverage<\/code> \u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 <code>&quot;build\/reports\/jacoco\/testBlueDebugUnitTestCoverage\/&quot;<\/code>.<\/p>\n<h2>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<ul>\n<li>2015-08-23: Fixed jacoco.gradle script for Gradle plugin 1.3.0, where test tasks are suffixed with \u00abUnitTest\u00bb.<\/li>\n<li>2015-10-01: Fixed task name suffixes in text.<\/li>\n<li>2015-10-28: Fixed build path changes for latest Android plugin.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/h2>\n<p>  <a href=\"https:\/\/github.com\/mgouline\/android-samples\/tree\/master\/jacoco\">JaCoCo example<\/a> (GitHub)       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/280374\/\"> https:\/\/habrahabr.ru\/post\/280374\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0410\u0432\u0442\u043e\u0440: Mike Gouline<br \/>  <a href=\"https:\/\/blog.gouline.net\/2015\/06\/23\/code-coverage-on-android-with-jacoco\/\">https:\/\/blog.gouline.net\/2015\/06\/23\/code-coverage-on-android-with-jacoco\/<\/a><br \/>  \u041f\u0435\u0440\u0435\u0432\u043e\u0434: \u0421\u0435\u043c\u0451\u043d \u0421\u043e\u043b\u0434\u0430\u0442\u0435\u043d\u043a\u043e<\/p>\n<p>  \u0421 \u0442\u0435\u0445 \u043f\u043e\u0440 \u043a\u0430\u043a \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 Android Gradle \u043f\u043b\u0430\u0433\u0438\u043d\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 0.10.0 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0431 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 (test coverage) \u2014 \u0438 \u044f \u043d\u0435 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u044e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u043b\u043b\u044e\u0437\u0438\u0439 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442, \u0442\u0430\u043a \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0434\u0430\u0436\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Gradle \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043e\u0442, \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u0441\u0431\u0435\u0440\u0435\u0447\u044c \u0432\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-277140","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277140"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277140\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}