请参阅相关的.NET问题
我正在寻找一种快速简便的方法来完成与分裂完全相反的方式,以便它 ["a","b","c"]能够成为"a,b,c"
迭代数组需要添加条件(如果这不是最后一个元素,添加分隔符)或使用子字符串删除最后一个分隔符.
我确信有一种经过认证的有效方法(Apache Commons?)
您更喜欢在项目中做到这一点?
需要帮助使用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)....