Skip to content

Instantly share code, notes, and snippets.

@dandvl
Created July 10, 2020 17:09
Show Gist options
  • Save dandvl/d28d79ad5ee373291b8f81b3d4995ca5 to your computer and use it in GitHub Desktop.
Save dandvl/d28d79ad5ee373291b8f81b3d4995ca5 to your computer and use it in GitHub Desktop.
UI Test Sample
package com.example.borrador2
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.rule.ActivityTestRule
import org.junit.Rule
import org.junit.Test
class ETest {
@get:Rule
var activity = ActivityTestRule(MainActivity::class.java)
@Test
fun wasItemLoaded(){
Thread.sleep(1000)
onView(withId(R.id.rvPosts))
.perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(2))
onView(ViewMatchers.withText("qui est esse"))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment