我有这个模拟类:
class MockCategoriesRepository implements CategoriesRepository {
@Override
public LiveData<List<Category>> getAllCategories() {
List<Category> categories = new ArrayList<>();
categories.add(new Category());
categories.add(new Category());
categories.add(new Category());
MutableLiveData<List<Category>> liveData = new MutableLiveData<>();
liveData.setValue(categories);
return liveData;
}
}
和测试:
@Test
public void getAllCategories() {
CategoriesRepository categoriesRepository = new MockCategoriesRepository();
LiveData<List<Category>> allCategories = categoriesRepository.getAllCategories();
}
我想测试List<Category>
是否为空。
我该如何做?我可以使用Mockito吗?