コンテキスト: WAMP (Windows の Service-Collection ではなく、Web Application Messaging Protocol) を使用する Web サービスを作成したいと考えています。イベントと RPC を非常に簡単な方法でサポートするため、WAMP を使用する必要があります。そして、より低いオーバーヘッドで。
すべてを手動で記述せずに、サービスの RPC メソッドを単体テストするにはどうすればよいでしょうか。
私の最初のアプローチは、Autobahn-JS と QUnit を組み合わせることでした。ここでの問題は、AutobahnJS がブロッキング "open()" メソッドをサポートしていないことです。そのため、QUnits beforeEach-hook によって開かれる接続が確実ではありません。次の例を参照してください。
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...
});
});
他の/より良いオプションはありますか?