I’m trying to test an object that has some Rx stuf...
# spek
r
I’m trying to test an object that has some Rx stuff during its
onBind
Copy code
disposables.add(dao.subscribeToVehicle(Consumer { updateView() }))
In writing tests around this object, I’m mocking
dao
using Mockito, which then requires me to stub the
subscribeToVehicle(consumer: Consumer<Boolean>)
so that it doesn’t return
null
. However, when I stub the method call
Copy code
Mockito.`when`(dao.subscribeToVehicle(any())).thenReturn(mock(Disposable::class.java))
Since
any()
returns
null
, it fails at runtime with
java.lang.IllegalStateException: any() must not be null
. Am I doing something wrong? It feels like this isn’t a problem with Spek or Kotlin, but I’ve scoured all the solutions related to this in Java and tangentially related in Kotlin, but nothing seems to fix my problem. This link looked like it was a solution to my problem, but the solution isn’t working and the only difference is that I’m using Spek: http://stackoverflow.com/a/30308199/981242 Any help would be greatly appreciated.