From 9667b3f61cd8c5341628217933b15b22c6bbe8cf Mon Sep 17 00:00:00 2001 From: Saul M Date: Mon, 4 Jan 2016 00:53:27 +0100 Subject: [PATCH] Fixed broken test --- app/build.gradle | 7 ++++++- .../java/saulmm/avengers/ApplicationTest.java | 14 -------------- ...aracterListActivityInstrumentationTest.java | 18 ++++++++++++++---- .../activities/CharacterDetailActivity.java | 2 +- build.gradle | 8 ++++---- 5 files changed, 25 insertions(+), 24 deletions(-) delete mode 100644 app/src/androidTest/java/saulmm/avengers/ApplicationTest.java rename app/src/androidTest/java/saulmm/avengers/{ => tests}/CharacterListActivityInstrumentationTest.java (75%) diff --git a/app/build.gradle b/app/build.gradle index a8adacf..679bb4c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,5 +72,10 @@ dependencies { exclude module: 'recyclerview-v7' } - androidTestCompile "com.android.support:support-annotations:$libs.supportVersion" + androidTestApt "com.google.dagger:dagger-compiler:${libs.dagger}" + } + +configurations.all { + resolutionStrategy.force "com.android.support:support-annotations:$libs.supportVersion" +} \ No newline at end of file diff --git a/app/src/androidTest/java/saulmm/avengers/ApplicationTest.java b/app/src/androidTest/java/saulmm/avengers/ApplicationTest.java deleted file mode 100644 index f1e8759..0000000 --- a/app/src/androidTest/java/saulmm/avengers/ApplicationTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package saulmm.avengers; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/saulmm/avengers/CharacterListActivityInstrumentationTest.java b/app/src/androidTest/java/saulmm/avengers/tests/CharacterListActivityInstrumentationTest.java similarity index 75% rename from app/src/androidTest/java/saulmm/avengers/CharacterListActivityInstrumentationTest.java rename to app/src/androidTest/java/saulmm/avengers/tests/CharacterListActivityInstrumentationTest.java index acee75a..9891509 100644 --- a/app/src/androidTest/java/saulmm/avengers/CharacterListActivityInstrumentationTest.java +++ b/app/src/androidTest/java/saulmm/avengers/tests/CharacterListActivityInstrumentationTest.java @@ -1,22 +1,28 @@ -package saulmm.avengers; +package saulmm.avengers.tests; import android.support.test.espresso.Espresso; import android.support.test.espresso.contrib.RecyclerViewActions; import android.support.test.espresso.intent.Intents; import android.support.test.espresso.intent.rule.IntentsTestRule; +import android.support.test.espresso.matcher.ViewMatchers; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import saulmm.avengers.R; +import saulmm.avengers.injector.components.DaggerAvengersComponent; +import saulmm.avengers.injector.modules.ActivityModule; import saulmm.avengers.repository.CharacterRepository; import saulmm.avengers.views.activities.CharacterDetailActivity; import saulmm.avengers.views.activities.CharacterListActivity; +import static android.support.test.espresso.Espresso.*; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.intent.Intents.intended; import static android.support.test.espresso.intent.Intents.times; @@ -31,11 +37,15 @@ public class CharacterListActivityInstrumentationTest { public IntentsTestRule mCharacterListIntentRule = new IntentsTestRule<>(CharacterListActivity.class); + @Before + public void setup() { + } + @Test - public void clickOnAvenger() { + public void testThatAClickOnTheAvengerOPensTheDetailActivity() { waitForRequest(); - Espresso.onView(withId(R.id.activity_avengers_recycler)) + onView(ViewMatchers.withId(R.id.activity_avengers_recycler)) .perform(RecyclerViewActions.actionOnItemAtPosition(0, click())); intended(hasComponent(CharacterDetailActivity.class.getCanonicalName())); @@ -43,7 +53,7 @@ public void clickOnAvenger() { public void waitForRequest() { try { - Thread.sleep(4000); + Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java b/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java index 2a64aec..7549b10 100644 --- a/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java +++ b/app/src/main/java/saulmm/avengers/views/activities/CharacterDetailActivity.java @@ -65,9 +65,9 @@ public void onReceive(Bitmap bitmap) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + initializeDependencyInjector(); initializeBinding(); initButterknife(); - initializeDependencyInjector(); initializePresenter(); initToolbar(); initTransitions(); diff --git a/build.gradle b/build.gradle index ec97d6c..7aaa14c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ ext { configuration = [ package : "saulmm.avengers", - buildToolsVersion : "23.0.1", + buildToolsVersion : "23.0.2", compileVersion : 23, minSdk : 21, targetSdk : 23, @@ -38,10 +38,10 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:2.0.0-alpha2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' - classpath 'me.tatarka:gradle-retrolambda:3.1.0' - classpath 'com.android.databinding:dataBinder:1.0-rc1' + classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta3' + classpath 'com.android.databinding:dataBinder:1.0-rc4' } }