Java Mockito不满意链接错误

Java Mockito不满意链接错误,java,unit-testing,junit,mocking,unsatisfiedlinkerror,Java,Unit Testing,Junit,Mocking,Unsatisfiedlinkerror,我得到一份工作 java.lang.UnsatifiedLink错误: NumberFormatCustom.toFixed(DI)Ljava/lang/String NumberFormatCustom.toFixed(本机方法) 错误中显示的方法toFix是在格式中调用的方法,我是否也必须模拟toFix的结果?我该怎么做 正如jny所述,Mockito无法模拟静态方法。试试PowerMock或JMockit我认为Mockito不适合静态方法。。。看看这个例子 @Test public voi

我得到一份工作

java.lang.UnsatifiedLink错误:

NumberFormatCustom.toFixed(DI)Ljava/lang/String

NumberFormatCustom.toFixed(本机方法)


错误中显示的方法toFix是在格式中调用的方法,我是否也必须模拟toFix的结果?我该怎么做

正如
jny
所述,
Mockito
无法模拟静态方法。试试
PowerMock
JMockit

我认为Mockito不适合静态方法。。。看看这个例子
@Test
public void prepareDeForFormTest() {
    assertEquals("", FormHelper.prepareDeForForm(null));
    Double myDouble = 123.;
    when(NumberFormatCustom.getIntegerInstance(true).format(myDouble)).thenReturn("123");
    assertEquals(FormHelper.prepareDeForForm(myDouble), NumberFormatCustom.getIntegerInstance(true).format(myDouble));
}