GithubHelp home page GithubHelp logo

hyleung / rx-testkit Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 195 KB

Extended TestSubscriber for RxJava

Home Page: http://hyleung.github.io/rx-testkit/

License: Other

Java 41.34% Groovy 55.38% Shell 3.28%

rx-testkit's Introduction

#RX TestKit: AssertJ for RxJava Build Status

This library provides a set of AssertJ assertions that can be used to make unit testing of RxJava code a little easier.

RxJava 2.x

via Maven:

<dependency>
    <groupId>com.github.hyleung</groupId>
    <artifactId>rx-testkit-java</artifactId>
    <version>2.0.0</version>
    <scope>test</scope>
</dependency>

via Gradle

test 'com.github.hyleung:rx-testkit-java:2.0.0'

RxJava 1.x

For RxJava 1.x, the latest release of this library is 1.1.0.

via Maven:

<dependency>
    <groupId>com.github.hyleung</groupId>
    <artifactId>rx-testkit-java</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
</dependency>

via Gradle

test 'com.github.hyleung:rx-testkit-java:1.1.0'

##Examples:

Assert that an Observable has completed…

Observable<String> observable = Observable.just("foo");

assertThat(observable)
    .hasCompleted();

…or hasn't completed:

Observable<String> observable = Observable.just("foo");

assertThat(observable)
    .hasNotCompleted();

…or has values (returns an AbstractListAssert)

Observable<String> observable = Observable.just("foo");

assertThat(observable)
    .values()
    .contains("foo");

…or emits a certain error (also returns an AbstractListAssert)

Exception myException = new Exception();

Observable<String> observable = Observable.error(myException);

assertThat(observable)
    .failures()
    .contains(myException);

...or mess around with time using a TestScheduler:

 TestScheduler scheduler = new TestScheduler();
 Observable<Integer> observable = Observable.just(1).delay(99, TimeUnit.MILLISECONDS, scheduler);

 assertThat(observable, scheduler)
         .after(100, TimeUnit.MILLISECONDS)
         .values()
         .isNotEmpty();

There's also support for rx.Single and rx.Completable.

rx-testkit's People

Contributors

hyleung avatar

Watchers

 avatar

rx-testkit's Issues

error in gradle import

in the readme file, instead of

test 'com.github.hyleung:rx-testkit-java:1.1.0'

there should be

testCompile 'com.github.hyleung:rx-testkit-java:1.1.0'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.