我有一个Cordova插件,该插件正在连接到android java中的aar库。我想使用JUnit或最佳的插件在此插件中执行单元测试
对于如何为此设置测试环境,我有些困惑。
MyappLauncherPlugin.java
public class MyappLauncherPlugin extends CordovaPlugin {
private static final String TAG = "MyappLauncherPlugin";
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Log.d(TAG, "Initializing MyappLauncherPlugin");
}
@Override
public void onNewIntent(Intent intent){
//Need to write code on receiving the intent
}
@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
final JSONArray methodArgs = args;
final CallbackContext callback = callbackContext;
final Launcher launcher = new Launcher();
if (action.equals("set")) {
final JSONObject queryArgs = methodArgs.getJSONObject(0);
final String userId = "{}";
final String userInfo = queryArgs.getString("userInfo");
cordova.getThreadPool().execute(new Runnable() {
public void run() {
launcher.setUser(userId, userInfo, cordova.getActivity(), new LauncherServerCallback() {
@Override
public void onSuccess(String response) {
callback.success(response);
}
@Override
public void onError(Throwable t) {
callback.error(t.getMessage());
}
});
}
else if(action.equals("launch")){
final JSONObject queryArgs = methodArgs.getJSONObject(0);
final String packageName = queryArgs.getString("packageName");
final String appName = queryArgs.getString("appName");
final String auxName = queryArgs.getString("auxName");
cordova.getThreadPool().execute(new Runnable() {
public void run() {
launcher.launchApp(appName, packageName, auxName, cordova.getActivity(), new LauncherServerCallback() {
@Override
public void onSuccess(String response) {
callback.success(response);
}
@Override
public void onError(Throwable t) {
callback.error(t.getMessage());
}
});
});
}
该项目的文件夹结构为
请帮助我。