Skip to content

BraisGabin/FragmentTestRule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

df4c29f · Jan 10, 2019

History

66 Commits
Jan 4, 2019
Jan 4, 2019
Jan 4, 2019
Jan 4, 2019
Nov 16, 2016
Jan 10, 2019
Nov 16, 2016
Jan 10, 2019
Jul 24, 2017
Jan 4, 2019
Jan 10, 2019
Nov 16, 2016
Nov 16, 2016
Nov 21, 2017

Repository files navigation

Fragment Test Rule

Test Fragments in isolation.

Download

androidTestImplementation 'com.21buttons:fragment-test-rule:2.0.1'
debugImplementation 'com.21buttons:fragment-test-rule-extras:2.0.1'

Note: If you don't support AndroidX yet use the version 1.1.0.

Usage

@Rule
public FragmentTestRule<?, FragmentWithoutActivityDependency> fragmentTestRule =
    FragmentTestRule.create(FragmentWithoutActivityDependency.class);

@Test
public void clickButton() throws Exception {
  onView(withText(R.string.button)).perform(click());

  onView(withText(R.string.button_clicked)).check(matches(isDisplayed()));
}

You can check the sample code for more examples.