Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Espresso version #432

Merged
merged 8 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ android {
}

dependencies {
api("androidx.test.espresso:espresso-core:3.1.1")
api("androidx.test.espresso:espresso-contrib:3.1.1")
api("androidx.test.espresso:espresso-core:3.4.0")
api("androidx.test.espresso:espresso-contrib:3.4.0")
api("androidx.test.uiautomator:uiautomator:2.2.0")
api("androidx.test.espresso:espresso-intents:3.1.1")
api("androidx.test.espresso:espresso-intents:3.4.0")


implementation("androidx.annotation:annotation:1.0.2")
implementation("androidx.legacy:legacy-support-core-ui:1.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class FlakyTestRule : TestRule {

override fun apply(base: Statement, description: Description): Statement {
return flakyStatementBuilder
.setBase(base)
.setDescription(description)
.build()
.setBase(base)
.setDescription(description)
.build()
}
}
2 changes: 1 addition & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
compileSdk = 30

defaultConfig {
minSdk = 19
minSdk = 21
targetSdk = 30

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.widget.EditText
import android.widget.ImageView
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.rule.ActivityTestRule
import androidx.test.runner.AndroidJUnit4
import com.adevinta.android.barista.assertion.BaristaAssertions.assertAny
import com.adevinta.android.barista.interaction.BaristaEditTextInteractions.writeTo
import com.adevinta.android.barista.internal.failurehandler.BaristaException
Expand All @@ -15,7 +14,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)

class AssertAnyTest {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.internal.failurehandler.BaristaException;
import com.adevinta.android.barista.internal.util.BaristaResourceTypeException;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaAssertions.assertThatBackButtonClosesTheApp;
import static com.adevinta.android.barista.assertion.BaristaBackgroundAssertions.assertHasAnyBackground;
Expand All @@ -31,7 +29,6 @@
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertNotExist;
import static junit.framework.Assert.fail;

@RunWith(AndroidJUnit4.class)
public class AssertionsTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.adevinta.android.barista.interaction.BaristaAutoCompleteTextViewInteractions.writeToAutoComplete;

@RunWith(AndroidJUnit4.class)
public class AutoCompleteTextViewTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.adevinta.android.barista.sample;

import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.rule.BaristaRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;

@RunWith(AndroidJUnit4.class)
public class BaristaRuleActivityTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.adevinta.android.barista.sample;

import androidx.test.espresso.intent.rule.IntentsTestRule;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaImageViewAssertions.assertHasAnyDrawable;
import static com.adevinta.android.barista.assertion.BaristaImageViewAssertions.assertHasNoDrawable;
import static com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera;
import static com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn;

@RunWith(AndroidJUnit4.class)
public class CameraTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class ChipsTest {
spyFailureHandlerRule.assertEspressoFailures(1)

assertThat(thrown).isInstanceOf(BaristaException::class.java)
.hasMessage("View (with id: com.adevinta.android.barista.sample:id/checkedChip) didn't match condition (not with checkbox state: is <true>)")
.hasMessage("View (view.getId() is <${R.id.checkedChip}/com.adevinta.android.barista.sample:id/checkedChip>)" +
" didn't match condition (not (an instance of android.view.View and an instance of android.widget.Checkable)" +
" and view.isChecked() matching: is <true>)")
.hasCauseInstanceOf(AssertionFailedError::class.java)
}

Expand All @@ -64,7 +66,8 @@ class ChipsTest {
spyFailureHandlerRule.assertEspressoFailures(1)

assertThat(thrown).isInstanceOf(BaristaException::class.java)
.hasMessage("View (with id: com.adevinta.android.barista.sample:id/singleSelectionChildGroup) didn't match condition (custom condition [use `assertionDescription` parameter on `assertAny` to setup descriptive message])")
.hasMessage("View (view.getId() is <${R.id.singleSelectionChildGroup}/com.adevinta.android.barista.sample:id/singleSelectionChildGroup>)" +
" didn't match condition (custom condition [use `assertionDescription` parameter on `assertAny` to setup descriptive message])")
.hasCauseInstanceOf(AssertionFailedError::class.java)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn;

@RunWith(AndroidJUnit4.class)
public class ClickInsideViewPagerTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.adevinta.android.barista.interaction.BaristaClickInteractions.clickBack;
import static com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn;

@RunWith(AndroidJUnit4.class)
public class ClickTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.internal.failurehandler.BaristaException;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertTextColorIs;
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertTextColorIsNot;

@RunWith(AndroidJUnit4.class)
public class ColorsSecondaryTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

import android.graphics.Color;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.internal.failurehandler.BaristaException;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertTextColorIs;
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertTextColorIsNot;

@RunWith(AndroidJUnit4.class)
public class ColorsTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class ContentDescriptionTest {
spyFailureHandlerRule.assertEspressoFailures(1)

assertThat(thrown).isInstanceOf(BaristaException::class.java)
.hasMessage("View (with id: com.adevinta.android.barista.sample:id/imageGreen) " +
"didn't match condition (with content description: Image color green)")
.hasMessage("View (view.getId() is <${R.id.imageGreen}/com.adevinta.android.barista.sample:id/imageGreen>)" +
" didn't match condition (with content description: Image color green)")
}

@Test
Expand All @@ -48,8 +48,7 @@ class ContentDescriptionTest {
spyFailureHandlerRule.assertEspressoFailures(1)

assertThat(thrown).isInstanceOf(BaristaException::class.java)
.hasMessage("View (with id: com.adevinta.android.barista.sample:id/imageGreen) " +
"didn't match condition (with content description)")
.hasMessage("View (view.getId() is <${R.id.imageGreen}/com.adevinta.android.barista.sample:id/imageGreen>) didn't match condition (with content description)")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn;
import static com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogNegativeButton;
import static com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogNeutralButton;
import static com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogPositiveButton;

@RunWith(AndroidJUnit4.class)
public class DialogActivityTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import androidx.core.view.GravityCompat;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaDrawerAssertions.assertDrawerIsClosed;
import static com.adevinta.android.barista.assertion.BaristaDrawerAssertions.assertDrawerIsClosedWithGravity;
Expand All @@ -19,7 +17,6 @@
import static com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDrawer;
import static com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDrawerWithGravity;

@RunWith(AndroidJUnit4.class)
public class DrawerActivityTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaHintAssertions.assertHint;
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.adevinta.android.barista.interaction.BaristaEditTextInteractions.clearText;
import static com.adevinta.android.barista.interaction.BaristaEditTextInteractions.typeTo;
import static com.adevinta.android.barista.interaction.BaristaEditTextInteractions.writeTo;

@RunWith(AndroidJUnit4.class)
public class EditTextTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public void baseFailureHandlerCalledOnce_withEspresso() throws Exception {
}

private void assertBaseHandlerCalledOnce() {
assertEquals(1, baseFailureHandler.getCapturedFailures().size());
assertEquals(1, baseFailureHandler.getCapturedFailuresCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)

class HelperTextTest {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.internal.failurehandler.BaristaException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaErrorAssertions.assertErrorDisplayed;
import static com.adevinta.android.barista.assertion.BaristaErrorAssertions.assertNoErrorDisplayed;
import static com.adevinta.android.barista.assertion.BaristaHintAssertions.assertHint;
import static com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn;

@RunWith(AndroidJUnit4.class)
public class HintAndErrorTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.adevinta.android.barista.sample.util.FailureHandlerValidatorRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertNotExist;
import static com.adevinta.android.barista.interaction.BaristaKeyboardInteractions.pressImeActionButton;

@RunWith(AndroidJUnit4.class)
public class KeyboardTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)

class ListViewAssertionTest {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.adevinta.android.barista.sample;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.adevinta.android.barista.assertion.BaristaListAssertions.assertDisplayedAtPosition;
import static com.adevinta.android.barista.interaction.BaristaSleepInteractions.sleep;
import static com.adevinta.android.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerBack;
import static com.adevinta.android.barista.interaction.BaristaViewPagerInteractions.swipeViewPagerForward;

@RunWith(AndroidJUnit4.class)
public class ListViewWithDifferentDataInsideViewPagerTest {

@Rule
Expand Down
Loading