Created
January 29, 2020 23:16
-
-
Save mfebrianto/c7692d6b3550d1650ed6a083854f56cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mock | |
import androidx.test.espresso.Espresso.onView | |
import androidx.test.espresso.action.ViewActions | |
import androidx.test.espresso.assertion.ViewAssertions | |
import androidx.test.espresso.matcher.ViewMatchers | |
import androidx.test.ext.junit.runners.AndroidJUnit4 | |
import androidx.test.rule.ActivityTestRule | |
import org.hamcrest.core.StringContains | |
import org.junit.Rule | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
@RunWith(AndroidJUnit4::class) | |
class ExampleInstrumentedTest { | |
@Rule @JvmField var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) | |
@Test | |
fun callAPI() { | |
onView(ViewMatchers.withId(R.id.button)).perform(ViewActions.click()) | |
//todo: sleep can avoided with many different way like timeout | |
Thread.sleep(5000) | |
onView(ViewMatchers.withId(R.id.hello_world)) | |
.check(ViewAssertions.matches(ViewMatchers.withText(StringContains.containsString("GMT")))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment