Debugging 深度相等(实际值、预期值、注释); start()//成功完成测试后调用start() }) .失败(功能(错误){ deepEqual(false,true,'不应调用失败回调'+error.toString()); start();//在测试失败后调用start() }); }); }(WLJQ))//结束保存测试的自动执行函数 }//结束wlCommonInit

Debugging 深度相等(实际值、预期值、注释); start()//成功完成测试后调用start() }) .失败(功能(错误){ deepEqual(false,true,'不应调用失败回调'+error.toString()); start();//在测试失败后调用start() }); }); }(WLJQ))//结束保存测试的自动执行函数 }//结束wlCommonInit,debugging,ibm-mobilefirst,jsonstore,Debugging,Ibm Mobilefirst,Jsonstore,上述代码的预期输出: 旁注:以下是一个关于特定开发人员的PhoneGap/Cordova工作流程的示例。不过,调试也有一部分,只是基于浏览器。其中一些也适用于IBM Worklight的开发。cnandreu在这里提供了很好的技巧。尽管如此,可见性还是很差,这些方法并没有真正解决我的问题。我还想建议我发现在我的项目中最有用的内容(除了WL.Logger.debug()之外): JSConsole是不可或缺的()。实际上,我并没有像预期的那样使用它。但是,我发现它的启动警告消息与WL.Logg

上述代码的预期输出:


旁注:以下是一个关于特定开发人员的PhoneGap/Cordova工作流程的示例。不过,调试也有一部分,只是基于浏览器。其中一些也适用于IBM Worklight的开发。

cnandreu在这里提供了很好的技巧。尽管如此,可见性还是很差,这些方法并没有真正解决我的问题。我还想建议我发现在我的项目中最有用的内容(除了WL.Logger.debug()之外):

  • JSConsole是不可或缺的()。实际上,我并没有像预期的那样使用它。但是,我发现它的启动警告消息与WL.Logger.debug()(和console.log())有关,使语句能够实际打印到控制台,以便我可以看到我在做什么

  • 在iOS 6中,Mac上的Safari允许您检查连接设备的DOM。它是相当有用的,特别是对于混合用户界面问题,这些问题只有在iOS上本机运行时才会出现问题。我不觉得它有什么特别的帮助。更多信息请访问

  • 我一直在使用的一种最有用的技术是将状态消息写入UI。是的,这是一种丑陋的史前方式,但其他一切——包括80年代错误打印到控制台的语句——都失败得很惨。下面是我的工作(使用Dojo和JavaScript):

    var v=dom.byId('audio_status');
    如果(v){v.innerHTML+=“录制文件[“+filename+”];}

其中
audio\u status
是显示调试内容的DIV的
ID


这东西很难看,但至少我们能看到一些东西。

谢谢你的详尽回答。为了澄清,将WL.Logger.debug()更改为console.log()不会改变我的代码。iOS模拟器控制台仍然只显示一些STMT,Xcode、Eclipse和Weinre都看不见它。阅读DB并将语句放入jsonstore.js是聪明的建议。正如使用Safari js调试器单步执行jsonstore.js一样。
$ adb shell
$ cd /data/data/com.[app-name]/databases/wljsonstore
$ sqlite3 jsonstore.sqlite
$ cd ~/Library/Application Support/iPhone Simulator/6.1/Applications/[id]/Documents/wljsonstore
$ sqlite3 jsonstore.sqlite
adb shell setprop log.tag.jsonstore-core VERBOSE
adb shell getprop log.tag.jsonstore-core
cdv.exec(options.onSuccess, options.onFailure, pluginName, nativeFunction, args);
deferred.resolve(data, more);
deferred.reject(new ErrorObject(errorObject));
<!DOCTYPE HTML>
<html>

<head>
    <title>JSONStore Test App</title>
    <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css">
    <script src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script>
    <script src="http://sinonjs.org/releases/sinon-1.6.0.js"></script>
    <script>
        //QUnit configuration flags, no need to change it.
        QUnit.config.requireExpects = true;
    </script>
</head>

<body id="content" style="display: none;">

    <!-- Test results will be appended to the div below, no need to make changes here. -->
    <div id="qunit"></div>

<script>

//Start Worklight
WL.Client.init({connectOnStartup : false});

//Hook into the deviceready event
document.addEventListener("deviceready", onDeviceReady, false);

//onDeviceReady will be called when JSONStore/Cordova is ready
function onDeviceReady () {

    //Auto executing function that holds the test
    (function (jQuery) { //The variable jQuery is usable inside.

        //Mock WL.Client.invokeProcedure using a Stub.
        //This is only useful if you need to link a Worklight Adapter
        //to a JSONStore collection to reproduce your issue or bug.
        //API Doc: http://sinonjs.org/docs/#stubs
        var fakeAdapter = sinon.stub(WL.Client, "invokeProcedure", function (invocationData, options) {

            //DO NOT Create a real adapter, just mock the reponse here if it's relevant to the bug.
            var ADAPTER_RESPONSE = {invocationResult: {fakeKey: [{fn: 'carlos'}, {fn: 'mike'}]}};
            options.onSuccess(ADAPTER_RESPONSE);
        });

        //[**Explain your test here**]
        var EXPECTED_ASSERTIONS = 2; //every assertion is a deepEqual below.
        asyncTest('[**Meaningful title here**]', EXPECTED_ASSERTIONS, function () {

            //Destroy first to make sure we don't depend on state
            WL.JSONStore.destroy()

            .then(function () {

                //[**Start writting your test here**]
                //The test below is an example, it does the following:
                // - Initializes a collection linked to a fake adapter (see stub above).
                // - Checks if initialization worked by checking the collection name.
                // - Loads data from the fake adapter (see stub above).
                // - Checks if load worked by checking the number of documents loaded.

                var collections = {
                    col1 : {
                        searchFields : {fn: 'string'},
                        adapter : {name: 'fakeAdapter',
                            load: {
                                procedure: 'fakeProcedure',
                                params: [],
                                key: 'fakeKey'
                            }
                        }
                    }
                };

                return WL.JSONStore.init(collections);
            })

            .then(function (response) {

                //Prep for your assertion
                var ACTUAL_VALUE = response.col1.name;
                var EXPECTED_VALUE = 'col1';
                var COMMENT = 'Checking for the right collection name';

                //Do your assertion using deepEqual
                //API Doc: http://api.qunitjs.com/deepEqual/
                deepEqual(ACTUAL_VALUE, EXPECTED_VALUE, COMMENT);

                return WL.JSONStore.get('col1').load();
            })

            .then(function (response) {

                //Prep for your assertion
                var ACTUAL_VALUE = response; //load returns number of documents loaded
                var EXPECTED_VALUE = 2; //two documents are returned by the fake adapter (stub)
                var COMMENT = 'Checking if load worked';

                //Do the assertion using deepEqual
                deepEqual(ACTUAL_VALUE, EXPECTED_VALUE, COMMENT);

                start();//call start() after you finish your test succesfully
            })

            .fail(function (error) {

                deepEqual(false, true, 'Failure callback should not be called' + error.toString());
                start();//call start() after you finish your test with a failure
            });

        });

    }(WLJQ)); //end auto executing function that holds the test

} //end wlCommonInit
</script>

</body>
</html>