Skip to content

Instantly share code, notes, and snippets.

@tomkoptel
Created April 14, 2018 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomkoptel/0972ebb829ae55c77700ca0d4de3442c to your computer and use it in GitHub Desktop.
Save tomkoptel/0972ebb829ae55c77700ca0d4de3442c to your computer and use it in GitHub Desktop.
Demonstrates usage of CoroutinesIdlingResourceRule in our UI test.
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.runner.AndroidJUnit4
import android.view.View
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
// https://gist.github.com/tomkoptel/1101b2bb61f3daf251e3d627ee533b92
import com.sample.CoroutinesIdlingResourceRule
@RunWith(AndroidJUnit4::class)
class MainActivityTest {
val launchRule = ActivityTestRule<MainActivity>(MainActivity::class.java)
val coroutinesRule = CoroutinesIdlingResourceRule()
@JvmField @Rule val chain = RuleChain.outerRule(coroutinesRule).around(launchRule)
@Test
fun some_test() {
onView(withId(R.id.text)).check(matches(withText("Result")))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment