我有一种使用jMockit进行模拟的方法。
class Test {
private Integer value = null;
public void testMethod(){
...
/*Logic to use Integer value which was initialized in some other method.*/
...
}
}
new MockUp<Indexer>() {
@MockUp
public void testMethod(){
...
/*Logic to use Integer value which was initialized in some other method.
Here getting compile time error for Integer value as is not declared in this mock scope.*/
...
}
}
我尝试了Integer value = Deencapsulation.getField(this, "value");
,但这样做:
java.lang.IllegalArgumentException:没有名称为“ value”的实例字段 在类嘲讽中找到。MockUp
您能建议我如何解决此问题吗?