【发布时间】:2018-10-02 09:22:08
【问题描述】:
我正在构建 react-native 应用程序,其中包含一些原生 android 模块。
在 MainApplication.java 中,
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new VectorIconsPackage(),
new MyCustomPackage()
);
}
在我的 MyCustomPackage 中,
public class MyCustomPackage implements ReactPackage {
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new MyCustomModule(reactContext));
return modules;
}
}
我有几个其他模块,但这是一个示例。所有功能都运行良好。现在我想为 MyCustomModule java 类中的方法编写单元测试。我尝试使用 Robolectric 框架,但不知道它是如何与 react native 一起工作的。有没有其他工具可以做到这一点?谁能给我一些示例或指导为 react-native 本机 android 代码编写单元测试?
【问题讨论】:
-
已经找到解决方案了吗?
-
没有。仍然没有找到解决方案。
标签: android unit-testing react-native react-native-android react-native-native-module