我正在尝试测试具有mongodb存储库的服务。我不知道如何编写利用它的测试,当我尝试从测试类创建条目时,当我从mongodb存储库中调用方法时,我一直在获取空指针异常。我的存储库类称为
TagPreferencesRepository
当我打电话时抛出异常
tagPreferencesRepository.deleteAllByProvider(provider);
I have declared TagPreferencesRepository
using @Mock
:
@Mock TagPreferencesRepository tagPreferencesRepository;
and the method throwing the exception is called from inside a method in the testing class, that is annotated with @Before