How to test a method using a Future in Dart?

Issue I would like to test a method which execute a POST on another server : Future executePost() { _client.post(“http://localhost/path”, body : ‘${data}’).then((response) { _logger.info(“Response status : ${response.statusCode}”); _logger.info(“Response body : ${response.body}”); Completer completer = new Completer(); completer.complete(true); return completer.future;

Continue reading

Dart Unit Test – Always passing

Issue All, Here is a unit test for checking the size of a collection main() { test(“Resource Manager Image Load”, () { ResourceManager rm = new ResourceManager(); int WRONG_SIZE = 1000000; rm.loadImageManifest(“data/rm/test_images.yaml”).then((_){ print(“Length=”+ rm.images.length.toString()); // PRINTS ‘6’ – WHICH IS

Continue reading

Dart Event Queue: How to debug event queue?

Issue I’m writing some integration tests which utilize an HttpServer, a bunch of Directory().watch()‘ers and possibly some other future/stream listening code. I’m using the following test configuration: class LaserServerTestConfiguration extends SimpleConfiguration { LaserServer _server; LaserServerTestConfiguration(this._server); void onDone(bool success) { super.onDone(success);

Continue reading