@Test
public void subscribeDisposeRace() {

    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        PublishSubject<Integer> ps = PublishSubject.create();
        final Completable c = ps.ignoreElements().cache();
        final TestObserver<Void> to1 = c.test();
        final TestObserver<Void> to2 = new TestObserver<Void>();
        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                to1.cancel();
            }
        };
        Runnable r2 = new Runnable() {
            @Override
            public void run() {
                c.subscribe(to2);
            }
        };
        TestHelper.race(r1, r2);
        ps.onComplete();
        to1.assertEmpty();
        to2.assertResult();
    }
}