需要帮助使用Mockito和JUnit4编写以下代码的单元测试,
public class MyFragmentPresenterImpl {
public Boolean isValid(String value) {
return !(TextUtils.isEmpty(value));
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法:MyFragmentPresenter mMyFragmentPresenter
@Before
public void setup(){
mMyFragmentPresenter=new MyFragmentPresenterImpl();
}
@Test
public void testEmptyValue() throws Exception {
String value=null;
assertFalse(mMyFragmentPresenter.isValid(value));
}
Run Code Online (Sandbox Code Playgroud)
但它返回以下异常,
java.lang.RuntimeException:未模拟android.text.TextUtils中的方法isEmpty.有关详细信息,请参阅http://g.co/androidstudio/not-mocked.在android.text.TextUtils.isEmpty(TextUtils.java)....