RxTestkit

AssertJ for RxJava

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.github.hyleung
ArtifactId

ArtifactId

rx-testkit-java
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

RxTestkit
AssertJ for RxJava
Project URL

Project URL

http://hyleung.github.io/rx-testkit/
Source Code Management

Source Code Management

https://github.com/hyleung/rx-testkit.git

Download rx-testkit-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.hyleung/rx-testkit-java/ -->
<dependency>
    <groupId>com.github.hyleung</groupId>
    <artifactId>rx-testkit-java</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.hyleung/rx-testkit-java/
implementation 'com.github.hyleung:rx-testkit-java:2.0.0'
// https://jarcasting.com/artifacts/com.github.hyleung/rx-testkit-java/
implementation ("com.github.hyleung:rx-testkit-java:2.0.0")
'com.github.hyleung:rx-testkit-java:jar:2.0.0'
<dependency org="com.github.hyleung" name="rx-testkit-java" rev="2.0.0">
  <artifact name="rx-testkit-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.hyleung', module='rx-testkit-java', version='2.0.0')
)
libraryDependencies += "com.github.hyleung" % "rx-testkit-java" % "2.0.0"
[com.github.hyleung/rx-testkit-java "2.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.assertj : assertj-core jar 2.2.0
io.reactivex.rxjava2 : rxjava jar 2.0.0
org.slf4j : slf4j-api jar 1.7.5

test (4)

Group / Artifact Type Version
junit : junit jar 4.11
org.spockframework : spock-core jar 1.0-groovy-2.4
org.mockito : mockito-core jar 1.10.19
org.codehaus.groovy : groovy-all jar 2.4.4

Project Modules

There are no modules declared in this project.

#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.

Versions

Version
2.0.0
1.1.0
1.0.0