Skip to content

TestScheduler and/or TestSubscriber doesn't work for nanoseconds #4883

@piotrturski

Description

@piotrturski

when millisecond resolution is used, everything works correctly. but the same test fails when all units are changed to nanosecond. the following test fails but should pass

import org.junit.Test;
import rx.Observable;
import rx.observers.TestSubscriber;
import rx.schedulers.TestScheduler;
import java.util.concurrent.TimeUnit;

public class NanosecondTest {

    @Test
    public void shoud_schedule_correctly_with_nanosecond_resolution() {

        TestScheduler scheduler = new TestScheduler();
        TestSubscriber<Long> testSubscriber = new TestSubscriber<>();

        TimeUnit unit = TimeUnit.NANOSECONDS; // change to TimeUnit.MILLISECONDS and test will pass

        Observable.interval(30, unit, scheduler).subscribe(testSubscriber);
        scheduler.advanceTimeTo(60, unit);

        testSubscriber.assertValues(0L, 1L);
    }
}

compile 'io.reactivex:rxjava:1.2.2'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions