Xpresso

Kotlin Android Espresso Extensions

License

License

GroupId

GroupId

it.czerwinski.android
ArtifactId

ArtifactId

xpresso-recyclerview
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

aar
Description

Description

Xpresso
Kotlin Android Espresso Extensions
Project URL

Project URL

https://czerwinski.it/projects/android-xpresso/
Source Code Management

Source Code Management

https://github.com/sczerwinski/android-xpresso

Download xpresso-recyclerview

How to add to project

<!-- https://jarcasting.com/artifacts/it.czerwinski.android/xpresso-recyclerview/ -->
<dependency>
    <groupId>it.czerwinski.android</groupId>
    <artifactId>xpresso-recyclerview</artifactId>
    <version>1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/it.czerwinski.android/xpresso-recyclerview/
implementation 'it.czerwinski.android:xpresso-recyclerview:1.0'
// https://jarcasting.com/artifacts/it.czerwinski.android/xpresso-recyclerview/
implementation ("it.czerwinski.android:xpresso-recyclerview:1.0")
'it.czerwinski.android:xpresso-recyclerview:aar:1.0'
<dependency org="it.czerwinski.android" name="xpresso-recyclerview" rev="1.0">
  <artifact name="xpresso-recyclerview" type="aar" />
</dependency>
@Grapes(
@Grab(group='it.czerwinski.android', module='xpresso-recyclerview', version='1.0')
)
libraryDependencies += "it.czerwinski.android" % "xpresso-recyclerview" % "1.0"
[it.czerwinski.android/xpresso-recyclerview "1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
androidx.recyclerview » recyclerview jar 1.1.0
androidx.test.espresso » espresso-contrib jar 3.3.0
it.czerwinski : kotlin-util jar 1.4.20

runtime (2)

Group / Artifact Type Version
it.czerwinski.android : xpresso-core jar 1.0
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.20

Project Modules

There are no modules declared in this project.

Build Release Snapshot Release

Xpresso: Kotlin Extensions for Android Espresso

Core

Maven Central Sonatype Nexus (Snapshots)

Build Configuration

dependencies {
    androidTestImplementation 'it.czerwinski.android:xpresso-core:1.0'
}

Examples

Launching ActivityScenario

@Test
fun myTestMethod() {
    val scenario = launchTestActivity<MyTestActivity>()
    // […]
}

Type-Aware View Interactions

on<TextView>(withText(R.string.hello_world))
    .check(isDisplayed())

on<Button>()
    .check(isDisplayed(), isEnabled())
    .perform(click())

Custom checks:

on<CheckBox>(withId(R.id.terms_and_conditions))
    .check {
        when (it) {
            is Success -> assertFalse(it.value.isChecked)
            is Failure -> assertTrue(it.exception is NoMatchingViewException)
        }
    }

Perform custom actions:

on<CalendarView>()
    .perform(description = "set date") {
        date = Date().time
    }

Bulk Checks

Perform check on all views in a bulk check:

bulkCheck {
    onView(withId(R.id.my_layout))
    on<CheckBox>()
    on<Button>(withText("OK"))
}.all(isDisplayed())

Assert that any of the views passes the check:

bulkCheckFor<Button> {
    onView(withText("OK"))
    onView(withText("Cancel"))
}.any(isEnabled())

RecyclerView

Maven Central Sonatype Nexus (Snapshots)

Build Configuration

dependencies {
    androidTestImplementation 'it.czerwinski.android:xpresso-recyclerview:1.0'
}

Examples

Interactions With Items Of RecyclerView

onRecyclerView(withId(R.id.list))
    .check(isDisplayed())
    .onItem<MyAdapter.ViewHolder>(position = 0) {
        // Interaction with ViewHolder.itemView
        check(hasDescendant(withText("Actions")))
        perform(click())
    }
    .onItem<MyAdapter.ViewHolder>(position = 1) {
        // Interaction with a descendant of ViewHolder.itemView:
        on<Button>(withText("Actions"))
            .check(isDisplayed())
            .perform(click())
    }

Versions

Version
1.0