1
簡單鏢問題之前,脈衝x1時,得到了一個流等待關於流繼續
Stream<Event>
我訂閱的單元測試。想是這樣的:
stream.listen(listener)
await listenerBeenNotified5Times
expect(result,expectation)
我知道expectAsync可以用來確保通知發生了5次,但我想等暫停執行,直到5個事件已流。
簡單鏢問題之前,脈衝x1時,得到了一個流等待關於流繼續
Stream<Event>
我訂閱的單元測試。想是這樣的:
stream.listen(listener)
await listenerBeenNotified5Times
expect(result,expectation)
我知道expectAsync可以用來確保通知發生了5次,但我想等暫停執行,直到5個事件已流。
var s = stream.take(5);
var subscription = s.listen(listener);
await susciption.asFuture;
或
await stream.take(5).toList();
這樣的作品,但只有當你不第5之後關心的事件原來的問題沒有具體說明應該發生的五個第一事件後聽什麼,所以這是一個很好的猜測。 – lrn
一如既往地感謝Günter,這爲我需要的測試工作。 – CarrKnight