6

我正在编写一些集成测试,这些测试利用了一个HttpServer,一堆Directory().watch()'ers,可能还有其他一些未来/流监听代码。

我正在使用以下测试配置:

class LaserServerTestConfiguration extends SimpleConfiguration {
  LaserServer _server;
  LaserServerTestConfiguration(this._server);
  void onDone(bool success) {
    super.onDone(success);
    _server.stop();
  }
}

我的测试看起来像这样:

main() {
  var conf = new LaserConfiguration.fromPath('test/test_config.yaml');
  var server = new LaserServer(conf);
  unittestConfiguration = new LaserServerTestConfiguration(server);

  server.start().then((_) {

    test('test file changed event', () {
      var response = new Completer<Map>();
      response.future.then(expectAsync((e) =>
        expect(e, containsValue('test/sample/sample_test.html'))
      ));
      WebSocket.connect("ws://localhost:2014").then((ws) {
        ws.listen((msg) {
          response.complete(JSON.decode(msg));
          ws.close();
        });
        new File('test/sample/sample.dart').writeAsString("");
      });
    });

  });
}

我遇到的问题是,在测试运行(并通过)后,Dart VM 没有退出。大概是因为我在事件队列中还有一些待处理的东西。

如何调试事件队列?我想看看是什么阻止了 Dart VM 在测试运行结束时退出。

您可以在自定义 TestConfiguration 中看到我重载了 onDone(),这被调用并且我 stop() 我的服务器(.close(force: true)在 HttpServer 上并循环我Directory().watch()的所有用户并取消订阅)。但是有些东西仍然悬而未决...

4

1 回答 1

1

天文台现在(Dart VM 版本:1.11.0-edge.131775)允许在调试器视图中调查消息队列。

于 2015-06-03T07:46:55.457 回答