{"id":265746,"date":"2015-09-16T13:31:02","date_gmt":"2015-09-16T09:31:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=265746"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=265746","title":{"rendered":"\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 Android: Robolectric + Jenkins + Ja\u0421o\u0421o"},"content":{"rendered":"<p>       \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u2014 \u0442\u0435\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u0435\u043c\u043a\u0430\u044f, \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e. \u041c\u044b \u0432 Rambler&#038;Co \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b \u043b\u044e\u0431\u0438\u043c, \u043f\u0438\u0448\u0435\u043c \u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f android (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e) \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041f\u043e\u043a\u0430\u0436\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Robolectric, JaCoCo \u0438 Jenkins, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 Android \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 Jenkins<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7b8\/2e0\/5a2\/7b82e05a2daa4ab1b4af5b0885c52115.png\"\/>  <\/div>\n<\/div>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>Robolectric<\/h5>\n<p>  Robolectric \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 JVM. \u0414\u0430, \u0434\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0436\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f apk, \u043f\u043e\u043a\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 JVM \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b. Android \u0441\u0440\u0435\u0434\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c. <\/p>\n<p>  Robolectric \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0432 \u043d\u0435\u0439 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c robolectric \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043c, \u0433\u0434\u0435 \u0447\u0438\u0441\u0442\u043e\u0433\u043e jUnit \u0443\u0436\u0435 \u043c\u0430\u043b\u043e, \u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u0432\u0430\u0439\u0441 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0414\u043b\u044f ui \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c <a href=\"https:\/\/code.google.com\/p\/android-test-kit\/wiki\/Espresso\">Espresso \u043e\u0442 Google<\/a>. <br \/>  \u0412 \u0441\u0435\u0442\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043f\u0440\u043e \u044d\u0442\u0443 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435.<\/p>\n<h6>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h6>\n<p>  \u0421 \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u0432\u0435\u0440\u0441\u0438\u0438 3.0 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0443\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 (\u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0441\u044f \u0435\u0449\u0435 \u0438 \u043f\u043b\u0430\u0433\u0438\u043d), \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 dependencies:<br \/>  <code> testCompile 'org.robolectric:robolectric:3.0' <\/code><\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 testCompile, \u0430 \u043d\u0435 androidTestCompile. testCompile \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f Unit Tests, \u0430 androidTestCompile \u2013 \u0434\u043b\u044f Android Instrumentation Test. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043e\u043a\u043e\u0448\u043a\u0435 build Variants, Test Artifact \u2014 Android Instrumentation Test, \u0436\u0434\u0435\u043c, \u043f\u043e\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0443\u0434\u0438\u044f, \u0438 \u0432\u0443\u0430\u043b\u044f\u2026 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u043f\u0430\u043b\u0438! \u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c?   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Build Variants<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/152\/d89\/374\/152d89374d2f45a4997bfe0e007b49f3.png\"\/><\/p><\/div>\n<\/div>\n<p>  \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043b\u044f unit \u0442\u0435\u0441\u0442\u043e\u0432 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f src\/test, \u0430 \u0434\u043b\u044f android test \u2014 src\/androidTest. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 src\\ \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438: \\test\\java \u0438 \\test\\resources. \u041f\u0435\u0440\u0432\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u0432\u0442\u043e\u0440\u0430\u044f \u0434\u043b\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c:<\/p>\n<pre><code class=\"java\">InputStream stream = getClass().getClassLoader().getResourceAsStream(&quot;habr.txt&quot;); <\/code><\/pre>\n<h6>\u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442<\/h6>\n<p>  \u041f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0434 robolectric \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0435\u0441\u0442\u044b, \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 setupActivity\\buildActivity. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, <a href=\"http:\/\/robolectric.org\/writing-a-test\/\">robolectric.org\/writing-a-test<\/a> <\/p>\n<pre><code class=\"java\"> @RunWith(RobolectricTestRunner.class) public class MyActivityTest {    @Test   public void clickingButton_shouldChangeResultsViewText() throws Exception {     MyActivity activity = Robolectric.setupActivity(MyActivity.class);      Button button = (Button) activity.findViewById(R.id.button);     TextView results = (TextView) activity.findViewById(R.id.results);      button.performClick();     assertThat(results.getText().toString()).isEqualTo(&quot;Robolectric Rocks!&quot;);   } }  <\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 (www.vogella.com)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">package com.vogella.android.test.robolectric;  import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.*; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat;  import com.example.BuildConfig;  import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricGradleTestRunner; import org.robolectric.annotation.Config; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.shadows.ShadowToast;  import android.content.Intent; import android.widget.Button;  @RunWith(RobolectricGradleTestRunner.class) @Config(constants = BuildConfig.class, sdk = 21, manifest = &quot;src\/main\/AndroidManifest.xml&quot;) public class MyActivityTest {    private MainActivity activity;    @Test   public void shouldHaveHappySmiles() throws Exception {     String hello = new MainActivity().getResources().getString(R.string.hello_world);     assertThat(hello, equalTo(&quot;Hello world!&quot;));   }    @Before   public void setup()  {     activity = Robolectric.buildActivity(MainActivity.class)         .create().get();   }   @Test   public void checkActivityNotNull() throws Exception {     assertNotNull(activity);   }      @Test   public void buttonClickShouldStartNewActivity() throws Exception    {       Button button = (Button) activity.findViewById(R.id.button2);       button.performClick();       Intent intent = Robolectric.shadowOf(activity).peekNextStartedActivity();       assertEquals(SecondActivity.class.getCanonicalName(), intent.getComponent().getClassName());   }      @Test   public void testButtonClick() throws Exception {     MainActivity activity = Robolectric.buildActivity(MainActivity.class)         .create().get();     Button view = (Button) activity.findViewById(R.id.button1);     assertNotNull(view);     view.performClick();     assertThat(ShadowToast.getTextOfLatestToast(), equalTo(&quot;Lala&quot;));   }           }   <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432 robolectric (\u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b robolectric):<br \/>  <a href=\"https:\/\/github.com\/robolectric\/robolectric-samples\">github.com\/robolectric\/robolectric-samples<\/a><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432 robolectric + espresso:<br \/>  <a href=\"https:\/\/github.com\/robolectric\/deckard\">github.com\/robolectric\/deckard<\/a> <\/p>\n<h6>\u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432<\/h6>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043d\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u0429\u0435\u043b\u043a\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u0435, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c Create \u00abtestName\u00bb, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e, \u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442\u0435 \u00ab\u041e\u041a\u00bb, \u0442\u0435\u0441\u0442 \u0433\u043e\u0442\u043e\u0432. \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a working directory \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\\app).\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b, \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\"> <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1e8\/17a\/815\/1e817a8154164107b694944f2ea768f8.png\"\/>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0435\u0441\u0442:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9b2\/fb7\/db5\/9b2fb7db5df24c34b2d3de5a26ca602c.png\"\/><\/p><\/div>\n<\/div>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 run \u2013 \u043e\u043a\u043e\u0448\u043a\u0435:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/23a\/7f4\/9a0\/23a7f49a01de40c4be4bf5ba9b436489.png\"\/><\/p><\/div>\n<\/div>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <br \/>  <code> gradlew test <\/code><\/p>\n<h5>JaCoCo<\/h5>\n<p>  \u0423\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0439 \u043f\u0440\u043e \u044d\u0442\u043e\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432 \u0440\u0443\u043d\u0435\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c.<br \/>  JaCoCo \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">JaCoCo \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/87a\/ad5\/2fb\/87aad52fbf254f1f95d6550d66d8d814.png\"\/> <\/p><\/div>\n<\/div>\n<p>  \u0421\u0430\u0439\u0442: <a href=\"http:\/\/www.eclemma.org\/jacoco\/\">www.eclemma.org\/jacoco<\/a> <br \/>  \u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 android, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0430\u0448 \u0444\u0430\u0439\u043b gradle:<\/p>\n<pre><code class=\"javascript\">apply plugin: 'jacoco'  jacoco {     toolVersion = &quot;0.7.1.201405082137&quot; }   def coverageSourceDirs = [         '..\/app\/src' ]  task jacocoTestReport(type: JacocoReport, dependsOn: &quot;testDebug&quot;) {     group = &quot;Reporting&quot;      description = &quot;Generate Jacoco coverage reports&quot;      classDirectories = fileTree(             dir: '..\/app\/build\/intermediates\/classes',             excludes: ['**\/R.class',                        '**\/R$*.class',                        '**\/*$ViewInjector*.*',                        '**\/BuildConfig.*',                        '**\/Manifest*.*']     )      additionalSourceDirs = files(coverageSourceDirs)     sourceDirectories = files(coverageSourceDirs)     executionData = files('..\/app\/build\/jacoco\/testDebug.exec')      reports {         xml.enabled = true         html.enabled = true     } }  <\/code><\/pre>\n<p>  \u0411\u0443\u0434\u044c\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b \u043f\u0440\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 executionData. \u042d\u0442\u043e \u043c\u0435\u0441\u0442\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f exec \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 gradlew jacocoTestReport. \u041e\u0442\u0447\u0435\u0442\u044b \u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435: build\\reports\\tests<br \/>  \u0415\u0441\u043b\u0438 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <br \/>  gradlew clean assemble test jacocoTestReport<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 html \u043e\u0442\u0447\u0435\u0442\u0430, \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0447\u0435\u0442\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a22\/fb6\/7d8\/a22fb67d85a041129217260fd2b9f18c.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d14\/cd1\/500\/d14cd150068243849a7762ec3972ef50.png\"\/>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f Jenkins \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0435\u043d\u0434 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0447\u0435\u0442\u043e\u0432 Jenkins<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ef5\/428\/439\/ef5428439f4b4d7db6e4f45aeb0f1ba4.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5b4\/99e\/47d\/5b499e47dbaa4ed4a6c410aca4368e23.png\"\/>  <\/div>\n<\/div>\n<h6>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Jenkins<\/h6>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 Jenkins. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442, \u0442\u043e \u0432\u043e\u0442 \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443: <a href=\"http:\/\/habrahabr.ru\/post\/205308\/\">habrahabr.ru\/post\/205308<\/a> <br \/>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u00ab\u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0435\u043c\u00bb \u043d\u0430\u0448 Jenkins: \u043d\u0430\u0443\u0447\u0438\u043c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0442\u0447\u0435\u0442\u044b \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Jenkins \u0431\u0435\u0437 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/939\/1c6\/f17\/9391c6f171f145a3b1c7800aa5771c6b.png\"\/><\/p><\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Jenkins \u0441 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7b8\/2e0\/5a2\/7b82e05a2daa4ab1b4af5b0885c52115.png\"\/><\/p><\/div>\n<\/div>\n<h6>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<br \/>  <\/h6>\n<p>  1) \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0437\u0430\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u0438 \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/HTML+Publisher+Plugin\">Publish html reports<\/a><br \/>  2) \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c <a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/JUnit+Plugin\">jUnit plugin<\/a> (\u0438\u043b\u0438 <a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/xUnit+Plugin\">xUnit Plugin<\/a>). <br \/>  3) \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c <a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/JaCoCo+Plugin\">JaCoCo Plugin<\/a>. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u0434\u043b\u044f exec \u0444\u0430\u0439\u043b\u043e\u0432, \u043a \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c. \u041f\u043e\u0447\u0442\u0438 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 build.gradle <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Publish html reports \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3f9\/516\/297\/3f9516297ebc4272a3e91e715f260707.png\"\/><\/p><\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 jUnit test result report \u0438 JaCoCo Plugin<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/358\/c81\/c2a\/358c81c2ae0a491ab510afa2709cef6f.png\"\/><\/p><\/div>\n<\/div>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0430\u043c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!               <\/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=\"http:\/\/habrahabr.ru\/post\/266837\/\"> http:\/\/habrahabr.ru\/post\/266837\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u2014 \u0442\u0435\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u0435\u043c\u043a\u0430\u044f, \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e. \u041c\u044b \u0432 Rambler&#038;Co \u0430\u0432\u0442\u043e\u0442\u0435\u0441\u0442\u044b \u043b\u044e\u0431\u0438\u043c, \u043f\u0438\u0448\u0435\u043c \u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f android (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e) \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041f\u043e\u043a\u0430\u0436\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Robolectric, JaCoCo \u0438 Jenkins, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 Android \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 Jenkins<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7b8\/2e0\/5a2\/7b82e05a2daa4ab1b4af5b0885c52115.png\"\/>  <\/div>\n<\/div>\n<p>  <\/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-265746","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265746","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=265746"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265746\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}