I am trying to use a TestSubscriber to unit test a function that receives an Observable. I am arranging the test using TestSubscriber and its onError call. When I try to assert using assertError I get an AssertionError: Exceptions differ; expected: java.net.SocketTimeoutException, actual: java.net.SocketTimeoutException.
My unit test:
// arrange
Mockito.when(mockJobRepository.getJobCountRefreshedTime()).thenReturn(0l);
Mockito.when(mockJobRepository.refreshJobCount()).thenReturn(Observable.just(1337));
TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
testSubscriber.onError(new SocketTimeoutException());
mockJobRepository.refreshJobCount().subscribe(testSubscriber);
// act
dashboardPresenter.onViewCreated();
// assert
testSubscriber.assertCompleted();
testSubscriber.assertError(new SocketTimeoutException());
I am trying to use a TestSubscriber to unit test a function that receives an Observable. I am arranging the test using
TestSubscriberand itsonErrorcall. When I try to assert usingassertErrorI get an AssertionError:Exceptions differ; expected: java.net.SocketTimeoutException, actual: java.net.SocketTimeoutException.My unit test: