All Projects → novoda → Rxpresso

novoda / Rxpresso

Licence: other
Easy Espresso UI testing for Android applications using RxJava.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxpresso

Ios Demos
Examples of ios applications http://www.novoda.com/blog
Stars: ✭ 85 (-77.21%)
Mutual labels:  novoda, open-source
Bintray Release
A helper for releasing from gradle up to bintray
Stars: ✭ 1,878 (+403.49%)
Mutual labels:  novoda, open-source
Gradle Build Properties Plugin
Keep your secrets secret. External build properties support for your Gradle scripts.
Stars: ✭ 110 (-70.51%)
Mutual labels:  novoda, open-source
Aosp.changelog.to
Generates a change log between different aosp tags. Based on the wonderful work of @alsutton
Stars: ✭ 12 (-96.78%)
Mutual labels:  novoda, open-source
Popular Movies App
A simple Android app, that helps user to discover movies. Project 1 & 2 of Udacity Android Developer Nanodegree.
Stars: ✭ 293 (-21.45%)
Mutual labels:  rxjava, android-application
Novoda
Common things for all Novoda's open source projects
Stars: ✭ 37 (-90.08%)
Mutual labels:  novoda, open-source
Simple Chrome Custom Tabs
Easy integration of Chrome Custom Tabs into your project. Just connect it to your activity, and navigate to the external website styling your tab as you wish.
Stars: ✭ 131 (-64.88%)
Mutual labels:  novoda, open-source
Download Manager
A library that handles long-running downloads, handling the network interactions and retrying downloads automatically after failures
Stars: ✭ 482 (+29.22%)
Mutual labels:  novoda, open-source
Kotlin Cleanarchitecture
This is a sample app that is part of a blog post I have written about how to architect android application using the Uncle Bob's clean architecture and Fernando Cejas Android-CleanArchitecture in Kotlin. Post in Spanish: http://katade.com/clean-architecture-kotlin/
Stars: ✭ 274 (-26.54%)
Mutual labels:  rxjava, android-application
No Player
Simplified Player wrapper for MediaPlayer and ExoPlayer
Stars: ✭ 182 (-51.21%)
Mutual labels:  novoda, open-source
Bonfire Firebase Sample
An app to discuss your favourite emojis. This is a sample app built with Firebase.
Stars: ✭ 564 (+51.21%)
Mutual labels:  novoda, open-source
Gradle Android Command Plugin
Handy commands for testing Android on CI
Stars: ✭ 349 (-6.43%)
Mutual labels:  novoda, open-source
Spikes
Where ideas & concepts are born & incubated
Stars: ✭ 540 (+44.77%)
Mutual labels:  novoda, open-source
Accessibilitools
UI tools to help make your Android app accessible.
Stars: ✭ 81 (-78.28%)
Mutual labels:  novoda, open-source
Merlin
Observes network connection status & gives callbacks
Stars: ✭ 536 (+43.7%)
Mutual labels:  novoda, open-source
Notils
Never again need a .utils. package yur scurvy sea dogs!
Stars: ✭ 126 (-66.22%)
Mutual labels:  novoda, open-source
Marvel
Marvel Characters Android Application Assigned by smava GmbH
Stars: ✭ 227 (-39.14%)
Mutual labels:  rxjava, android-application
Gradle Static Analysis Plugin
Easy setup of static analysis tools for Android and Java projects.
Stars: ✭ 398 (+6.7%)
Mutual labels:  novoda, open-source
Android Demos
Examples of Android applications
Stars: ✭ 1,963 (+426.27%)
Mutual labels:  novoda, open-source
Sqlite Provider
Extended SQLite functionality for Android
Stars: ✭ 312 (-16.35%)
Mutual labels:  novoda, open-source

UNMAINTAINED

No maintainance is intended.

RxPresso CI status Download from Bintray Apache 2.0 Licence

Easy Espresso UI testing for Android applications using RxJava.

Description

RxPresso makes testing your presentation layer using RxJava as easy as a Unit test.

RxPresso uses Mockito to generate mocks of your repositories that you can use with RxPresso to control data in your Espresso tests. The binding with Espresso Idling resource is handled for you so Espresso will wait until the data you expect to inject in your UI has been delivered to you UI.

No more data you don't control in your Espresso test.

This project is in its early stages, feel free to comment, and contribute back to help us improve it.

Adding to your project

To integrate RxPresso into your project, add the following at the beginning of the build.gradle of your project:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        androidTestCompile 'com.novoda:rxpresso:0.2.0'
    }
}

Simple usage

To generate a mocked repo simply use Mockito.

Example repository

public interface DataRepository {

    Observable<User> getUser(String id);

    Observable<Articles> getArticles();

}

Mocking this repository

DataRepository mockedRepo = Mockito.mock(DataRepository.class)

You should then replace the repository used by your activities by this mocked one. If you use Dagger or Dagger2 you can replace the module by a test one providing the mock. If your repo lives in the application class you can have a setter or user reflection to set it during tests. Any other option as long as your UI reads from the mocked repo.

Set up RxPresso in your tests

DataRepository mockedRepo = getSameRepoUsedByUi();

RxPresso rxpresso = RxPresso.from(mockedRepo);
Espresso.registerIdlingResources(rxPresso);

Use it to inject data in your UI

rxPresso.given(mockedRepo.getUser("id"))
           .withEventsFrom(Observable.just(new User("some name")))
           .expect(any(User.class))
           .thenOnView(withText("some name"))
           .perform(click());

Use it to inject data from local sources

Observable<User> testAssetObservable = testAssetRepo.getUser("id");

rxPresso.given(mockedRepo.getUser("id"))
           .withEventsFrom(testAssetObservable)
           .expect(any(User.class))
           .thenOnView(withText("some name"))
           .perform(click());

Use custom matchers

Observable<User> testAssetObservable = testAssetRepo.getUser("id");

rxPresso.given(mockedRepo.getUser("id"))
           .withEventsFrom(testAssetObservable)
           .expect(new RxMatcher<Notification<User>>() {
                   @Override
                   public boolean matches(Notification<User> actual) {
                       return actual.getValue().name().equals("some name");
                   }

                   @Override
                   public String description() {
                       return "User with name " + "some name";
                   }
           })
           .thenOnView(withText("some name"))
           .perform(click());

Use it to inject errors in your UI

rxPresso.given(mockedRepo.getUser("id"))
           .withEventsFrom(Observable.error(new CustomError()))
           .expect(anyError(User.class, CustomError.class))
           .thenOnView(withText("Custom Error Message"))
           .matches(isDisplayed());

Reset mocks between tests

rxPresso.resetMocks();

You can also use RxPresso with multiple repositories. Just setup using all the repositories your UI is using. The usage doesn't change RxPresso will detect from what repo the observable provided comes from and send the data to the correct pipeline.

Setup with multiple repositories

DataRepository mockedRepo = getSameRepoUsedByUi();
AnotherDataRepository mockedRepo2 = getSameSecondRepoUsedByUi();


RxPresso rxpresso = RxPresso.from(mockedRepo, mockedRepo2);
Espresso.registerIdlingResources(rxPresso);

Links

Here are a list of useful links:

  • We always welcome people to contribute new features or bug fixes, here is how
  • If you have a problem check the Issues Page first to see if we are working on it
  • Looking for community help, browse the already asked Stack Overflow Questions or use the tag: support-rxpresso when posting a new question
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].