I am trying to test stream events in my service, and faced a problem: is any way to synchronously deliver events in async stream? Here is simplified code example:
test("deliver event", () {
StreamController sc = new StreamController();
String v = "old";
sc.stream.listen((val) {v = val;});
sc.add("new");
expect(v, "new"); // test fails: actual value is "old"
});
Aucun commentaire:
Enregistrer un commentaire