Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJava2 TestObserver class - where is getOnNextEvent similar to TestSubscriber class?

I am searching for a way to get the values returned from onNext in a subscriber so i can verify the results. TestSubscriber had a nice method called getOnNextEvent but when i use TestObserver i dont see a method like this i can use so that i can get the results to check it ? There all deprecated and when i check in the IDE there not even showing up.

Here is what i want to test:

`@Test
   public void buildUseCaseObservable(){

TestObserver subscriber = TestObserver.create();
standardLoginUsecase.buildUseCaseObservable().subscribe(subscriber);

      subscriber.assertNoErrors();
      subscriber.assertSubscribed();
      subscriber.assertComplete();
      //i would like to test the actual onNext results also , but how ?
  }`

UPDATE: I FOUND a getEvents method but its deprecated. i dont see any alternative though.

like image 477
j2emanue Avatar asked Jun 10 '17 08:06

j2emanue


1 Answers

TestObserver<List<User>> testObserver = new TestObserver<>();
testObserver.values();

Use values method to test the onNext Items

like image 68
Sam Avatar answered Oct 23 '22 03:10

Sam