Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 如何测试WAMP服务?_Unit Testing_Qunit_Autobahn_Wamp Protocol - Fatal编程技术网

Unit testing 如何测试WAMP服务?

Unit testing 如何测试WAMP服务?,unit-testing,qunit,autobahn,wamp-protocol,Unit Testing,Qunit,Autobahn,Wamp Protocol,上下文:我想编写一个使用WAMP(web应用程序消息传递协议,而不是Windows的服务集合)的web服务。应该使用WAMP,因为它以一种非常简单的方式支持事件和RPC。并且具有较低的开销 现在,我如何在不手工编写所有内容的情况下对服务的RPC方法进行单元测试 我的第一个方法是一起乘坐高速公路JS和QUnit。这里的问题是AutobahnJS不支持阻塞“open()”方法。因此,我不能确定在每个钩子之前由QUNIT打开的连接。请参见此示例: var connection; QUnit.modu

上下文:我想编写一个使用WAMP(web应用程序消息传递协议,而不是Windows的服务集合)的web服务。应该使用WAMP,因为它以一种非常简单的方式支持事件和RPC。并且具有较低的开销

现在,我如何在不手工编写所有内容的情况下对服务的RPC方法进行单元测试

我的第一个方法是一起乘坐高速公路JS和QUnit。这里的问题是AutobahnJS不支持阻塞“open()”方法。因此,我不能确定在每个钩子之前由QUNIT打开的连接。请参见此示例:

var connection;

QUnit.module("Module 1", function(hooks) {    
    hooks.beforeEach(function(assert) {
        // insert something executed before each test
        connection = new autobahn.Connection({
            url: wstarget,
            realm: wsrealm
        });
        connection.open();
    });

    QUnit.test( "check something", function( assert ) {
        assert.ok(connection.isConnected == true);
        // do something here that requires open connection...
    }); 
});

还有其他/更好的选择吗?

由同事提供的解决方案:

QUnit提供了一种允许异步测试的方法。它的用法有点像提交数据库事务。我必须准备好,我期待着你的回电

var asyncOp = assert.async();
并用

在回调函数内部


来源:

同事提供的解决方案:

QUnit提供了一种允许异步测试的方法。它的用法有点像提交数据库事务。我必须准备好,我期待着你的回电

var asyncOp = assert.async();
并用

在回调函数内部

资料来源: