3

For unit testing in kotlin android, I have been using the mocking framework MockK. Have used RxKotlin. I have used Completable observable to notify the ViewModel about the status of API. Based on the completable, the status will be updated to success or failure in ViewModel. My question is how to mock the completable observable of RxKotlin using MockK and check the status in the unit test function based on the mocked completable.

Snippet

val testObserver = TestObserver<T>()

every {
 mocked api call
} return completable

testobserver.assertComplete()

unknown

How to subscribe the testobserver with the completable return mock function call

Raghul Vaikundam
  • 588
  • 4
  • 20

0 Answers0