Reputation: 621
I have some method:
repository.get(arg1, arg2, arg3)
Method return Single<List<SomeObject>>
I need testing that Single was called onSubscribe()
with specific arguments.
repository.get(arg1, arg2, arg3)
.test()
.assertSubscribed()
This method ignores arguments which I put in method repository.get()
.
How I can test that subscribe called with certain arguments?
Upvotes: 0
Views: 53
Reputation: 1389
use Schedulers.trampoline()
to make the subscription occur on the current thread. then you can assert the required args
@Before
fun setup() {
RxJavaPlugins.setIoSchedulerHandler { Schedulers.trampoline() }
RxJavaPlugins.setComputationSchedulerHandler { Schedulers.trampoline() }
}
this makes the code run on the current thread. then you can assert the args
repository.get(arg1, arg2, arg3)
.test()
.subscribe {
// do the assertions here
}
Upvotes: 1