对于空字符串,它应该返回true.
从TextUtils的源代码:
public static boolean isEmpty(@Nullable CharSequence str) {
if (str == null || str.length() == 0)
return true;
else
return false;
}
在测试中尝试使用以下内容:
mockStatic(TextUtils.class);
when(TextUtils.isEmpty(any(CharSequence.class))).thenAnswer(new Answer() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
String string = (String) args[0];
return (string == null || string.length() == 0);
}
});