diff --git a/.travis.yml b/.travis.yml index 0f3726f4..1767922b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,12 @@ language: android jdk: oraclejdk8 +before_script: + - echo y | android update sdk --no-ui --all --filter build-tools-23.0.1 + - echo y | android update sdk --no-ui --all --filter android-23 + - echo y | android update sdk --no-ui --all --filter extra-android-support + - echo y | android update sdk --no-ui --all --filter extra-android-m2repository + android: components: - build-tools-23.0.1 diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle index 7ce44705..becdd587 100644 --- a/buildsystem/dependencies.gradle +++ b/buildsystem/dependencies.gradle @@ -15,11 +15,11 @@ ext { daggerVersion = '2.0.2' butterKnifeVersion = '7.0.1' recyclerViewVersion = '21.0.3' - rxJavaVersion = '1.0.14' + rxJavaVersion = '1.0.16' rxAndroidVersion = '1.0.1' javaxAnnotationVersion = '1.0' - gsonVersion = '2.3' - okHttpVersion = '2.5.0' + gsonVersion = '2.4' + okHttpVersion = '2.6.0' androidAnnotationsVersion = '21.0.3' //Testing @@ -28,8 +28,8 @@ ext { assertJVersion = '1.7.1' mockitoVersion = '1.9.5' dexmakerVersion = '1.0' - espressoVersion = '2.0' - testingSupportLibVersion = '0.1' + espressoVersion = '2.2.1' + testingSupportLibVersion = '0.4.1' presentationDependencies = [ @@ -47,7 +47,8 @@ ext { dexmaker: "com.google.dexmaker:dexmaker:${dexmakerVersion}", dexmakerMockito: "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}", espresso: "com.android.support.test.espresso:espresso-core:${espressoVersion}", - testingSupportLib: "com.android.support.test:testing-support-lib:${testingSupportLibVersion}", + testRules: "com.android.support.test:rules:${testingSupportLibVersion}", + testRunner: "com.android.support.test:rules:${testingSupportLibVersion}" ] domainDependencies = [ diff --git a/presentation/build.gradle b/presentation/build.gradle index 5c256f46..7556a108 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -76,6 +76,13 @@ dependencies { androidTestCompile presentationTestDependencies.mockito androidTestCompile presentationTestDependencies.dexmaker androidTestCompile presentationTestDependencies.dexmakerMockito - androidTestCompile presentationTestDependencies.espresso - androidTestCompile presentationTestDependencies.testingSupportLib + androidTestCompile (presentationTestDependencies.espresso) { + exclude group: 'com.android.support', module: 'support-annotations' + } + androidTestCompile (presentationTestDependencies.testRules) { + exclude group: 'com.android.support', module: 'support-annotations' + } + androidTestCompile (presentationTestDependencies.testRunner) { + exclude group: 'com.android.support', module: 'support-annotations' + } } diff --git a/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserDetailsActivityTest.java b/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserDetailsActivityTest.java index 3a8f0735..8305f25c 100644 --- a/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserDetailsActivityTest.java +++ b/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserDetailsActivityTest.java @@ -17,9 +17,15 @@ import android.app.Fragment; import android.content.Intent; -import android.test.ActivityInstrumentationTestCase2; +import android.support.test.InstrumentationRegistry; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; import com.fernandocejas.android10.sample.presentation.R; import com.fernandocejas.android10.sample.presentation.view.activity.UserDetailsActivity; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; @@ -31,38 +37,39 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.not; -public class UserDetailsActivityTest extends ActivityInstrumentationTestCase2 { +@RunWith(AndroidJUnit4.class) +public class UserDetailsActivityTest { private static final int FAKE_USER_ID = 10; - private UserDetailsActivity userDetailsActivity; - - public UserDetailsActivityTest() { - super(UserDetailsActivity.class); - } + @Rule public ActivityTestRule activityRule = new ActivityTestRule<>( + UserDetailsActivity.class, + true, // initialTouchMode + false); // launchActivity. False to set up mocks before activity launch - @Override protected void setUp() throws Exception { - super.setUp(); - this.setActivityIntent(createTargetIntent()); - this.userDetailsActivity = getActivity(); - } + private UserDetailsActivity userDetailsActivity; - @Override protected void tearDown() throws Exception { - super.tearDown(); + @Before public void setUp() { + activityRule.launchActivity(createTargetIntent()); + userDetailsActivity = activityRule.getActivity(); } + @Test public void testContainsUserDetailsFragment() { Fragment userDetailsFragment = userDetailsActivity.getFragmentManager().findFragmentById(R.id.fl_fragment); assertThat(userDetailsFragment, is(notNullValue())); } + @Test public void testContainsProperTitle() { + String actualTitle = this.userDetailsActivity.getTitle().toString().trim(); assertThat(actualTitle, is("User Details")); } + @Test public void testLoadUserHappyCaseViews() { onView(withId(R.id.rl_retry)).check(matches(not(isDisplayed()))); onView(withId(R.id.rl_progress)).check(matches(not(isDisplayed()))); @@ -72,6 +79,7 @@ public void testLoadUserHappyCaseViews() { onView(withId(R.id.tv_description)).check(matches(isDisplayed())); } + @Test public void testLoadUserHappyCaseData() { onView(withId(R.id.tv_fullname)).check(matches(withText("John Sanchez"))); onView(withId(R.id.tv_email)).check(matches(withText("dmedina@katz.edu"))); @@ -80,7 +88,7 @@ public void testLoadUserHappyCaseData() { private Intent createTargetIntent() { Intent intentLaunchActivity = - UserDetailsActivity.getCallingIntent(getInstrumentation().getTargetContext(), FAKE_USER_ID); + UserDetailsActivity.getCallingIntent(InstrumentationRegistry.getTargetContext(), FAKE_USER_ID); return intentLaunchActivity; } diff --git a/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserListActivityTest.java b/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserListActivityTest.java index ceaf761c..0926583e 100644 --- a/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserListActivityTest.java +++ b/presentation/src/androidTest/java/com/fernandocejas/android10/sample/test/view/activity/UserListActivityTest.java @@ -17,38 +17,43 @@ import android.app.Fragment; import android.content.Intent; -import android.test.ActivityInstrumentationTestCase2; +import android.support.test.InstrumentationRegistry; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; import com.fernandocejas.android10.sample.presentation.R; import com.fernandocejas.android10.sample.presentation.view.activity.UserListActivity; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -public class UserListActivityTest extends ActivityInstrumentationTestCase2 { +@RunWith(AndroidJUnit4.class) +public class UserListActivityTest { private UserListActivity userListActivity; - public UserListActivityTest() { - super(UserListActivity.class); - } - - @Override protected void setUp() throws Exception { - super.setUp(); - this.setActivityIntent(createTargetIntent()); - userListActivity = getActivity(); - } + @Rule public ActivityTestRule activityRule = new ActivityTestRule<>( + UserListActivity.class, + true, // initialTouchMode + false); // launchActivity. False to set up mocks before activity launch - @Override protected void tearDown() throws Exception { - super.tearDown(); + @Before public void setUp() { + activityRule.launchActivity(createTargetIntent()); + userListActivity = activityRule.getActivity(); } + @Test public void testContainsUserListFragment() { Fragment userListFragment = userListActivity.getFragmentManager().findFragmentById(R.id.fragmentUserList); assertThat(userListFragment, is(notNullValue())); } + @Test public void testContainsProperTitle() { String actualTitle = this.userListActivity.getTitle().toString().trim(); @@ -57,7 +62,7 @@ public void testContainsProperTitle() { private Intent createTargetIntent() { Intent intentLaunchActivity = - UserListActivity.getCallingIntent(getInstrumentation().getTargetContext()); + UserListActivity.getCallingIntent(InstrumentationRegistry.getTargetContext()); return intentLaunchActivity; }