@Test
public void doOnError() {

    final int[] count = { 0 };
    Flowable.range(1, 5)
    .parallel(2)
    .map(new Function<Integer, Integer>() {
        @Override
        public Integer apply(Integer v) throws Exception {
            if (v == 3) {
                throw new TestException();
            }
            return v;
        }
    })
    .doOnError(new Consumer<Throwable>() {
        @Override
        public void accept(Throwable e) throws Exception {
            if (e instanceof TestException) {
                count[0]++;
            }
        }
    })
    .sequential()
    .test()
    .assertError(TestException.class)
    .assertNotComplete();
    assertEquals(1, count[0]);
}