Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/braisgabin/fragmenttestrule

JUnit Rule to test a Fragment in isolation
https://github.com/braisgabin/fragmenttestrule

android android-testing espresso junit-rule

Last synced: 8 days ago
JSON representation

JUnit Rule to test a Fragment in isolation

Awesome Lists containing this project

README

        

# Fragment Test Rule

Test `Fragment`s in isolation.

## Download

```gradle
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

```java
@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.