在react本地库中,有一个类别https://github.com/facebook/react-native/blob/master/master/reactandroid/src/src/main/java/java/java/com/com/face/face/face/reactbook/react用于捆绑的/布里奇/arguments.java。我正在使用powermockito模拟gruments.createmap()方法,并返回一个具有以下片段的对象:
PowerMockito.when(Arguments.createMap()).thenAnswer(
new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return new JavaOnlyMap();
}
});
测试运行时,我正在测试错误的方法:
java.lang.UnsatisfiedLinkError: no reactnativejni in java.library.path
执行此行时:
WritableMap map = Arguments.createMap();
有什么想法?
将Answer<Object>
提取到变量。使用new
操作员用作参数时,Mockito不喜欢它。
尝试这样的事情:
Answer<Object> answer = new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return new JavaOnlyMap();
}
}
PowerMockito.when(Arguments.createMap()).thenAnswer(answer);