add espresso test for BoardsListActivity

This commit is contained in:
Raffaele Mignone 2019-12-29 23:09:37 +01:00
parent 60834d1a01
commit 4253074679
Signed by: norangebit
GPG Key ID: F5255658CB220573
2 changed files with 56 additions and 0 deletions

View File

@ -67,6 +67,10 @@ dependencies {
testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1" testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1"
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
implementation "com.squareup.retrofit2:retrofit:2.6.2" implementation "com.squareup.retrofit2:retrofit:2.6.2"
implementation "com.squareup.retrofit2:converter-gson:2.6.2" implementation "com.squareup.retrofit2:converter-gson:2.6.2"

View File

@ -0,0 +1,52 @@
package it.unisannio.ding.ids.wedroid.app.view
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.action.ViewActions.swipeLeft
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import it.unisannio.ding.ids.wedroid.app.R
import it.unisannio.ding.ids.wedroid.app.view.adapter.BoardsListAdapter
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@LargeTest
class BoardsListsActivityTest {
@get:Rule
val activityRule = ActivityTestRule(BoardsListsActivity::class.java)
fun swipeLeftToDelete() {
onView(withId(R.id.boardList))
.perform(
RecyclerViewActions.actionOnItemAtPosition<BoardsListAdapter.BoardViewHolder>(
0, swipeLeft()
)
)
}
fun pullToRefresh() {
onView(withId(R.id.pullToRefresh))
.perform(swipeDown())
}
@Test
fun openNewBoardActivity() {
onView(withId(R.id.fab))
.perform(click())
onView(withId(R.id.newBoardName))
.check(matches(isDisplayed()))
}
}