Git Product home page Git Product logo

assertj-rx's Introduction

Deprecated

Assertj-rx is now deprecated. In-order to test observabales, please use the TestSubscriber - more information on this can be found here. Whilst the current version still remains usable, there will no longer be any new development taking place.

AssertJ RxJava

AssertJ assertions for RxJava Observables.

This library extends AssertJ core with the aim of providing elegant assertions to test RxJava Observables. The current version of this library only provides assertions aimed at testing "cold" Observables. You will need to transform your Observable into a BlockingObservable before performing any assertion.

Feedback and contributions are very welcome.

##Examples

  • Assert that completes successfully without emitting any error:
assertThat(observable.toBlocking()).completes();
  • Assert that completes after emitting a single value "hello":
assertThat(observable.toBlocking())
    .completes()
    .emitsSingleValue("hello");
  • Assert that completes without emitting any value:
assertThat(observable.toBlocking())
    .completes()
    .emitsNoValues();
  • Assert that emits an error:
assertThat(observable.toBlocking()).fails();
  • Assert that emits an error of type IllegalArgumentException
assertThat(observable.toBlocking())
    .failsWithError(IllegalArgumentException.class);
  • Assert that completes after emitting three values that are exactly "a", "b" and "c":
assertThat(observable.toBlocking())
    .completes()
    .listOfValuesEmitted()
    .containsExactly("a", "b", "c");
  • Assert that fails after emitting "a" and "b":
assertThat(observable.toBlocking())
    .fails()
    .listOfValuesEmitted()
    .containsExactly("a", "b");
  • Assert that completes after emitting 10 values
assertThat(observable.toBlocking())
   .completes()
   .valuesCountIs(10);

Installation

Artifacts are on Maven central.

Gradle:

testCompile 'uk.co.ribot.assertj-rx:assertj-rx:0.1.0'

Maven:

<dependency>
  <groupId>uk.co.ribot.assertj-rx</groupId>
  <artifactId>assertj-rx</artifactId>
  <version>0.1.0</version>
  <scope>test</scope>
</dependency>

Alternatively, you can download the jar from the releases section.

License

Copyright (C) 2015 Ribot Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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.