我想测试单次返回null时的条件
when(repository.getSubLocations(ID)).thenReturn(Single.just(null));
但它给了我错误
at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39)
答案 0 :(得分:0)
我找到了解决方案,而不是这样做
when(repository.getSubLocations(ID)).thenReturn(Single.just(null));
我这样做
when(repository.getSubLocations(ID)).thenReturn(Single.just(SOME_DATA).map(data -> null));
所以现在我可以成功测试空状态