I was trying this method expectAsync2
, so there was this question: Why the async test passed, but there are some error messages displayed?
But it seems I didn't use it correctly. Is there any good example of expectAsync2
?
I was trying this method expectAsync2
, so there was this question: Why the async test passed, but there are some error messages displayed?
But it seems I didn't use it correctly. Is there any good example of expectAsync2
?
In the referenced question
expectAsync
was just used to guard a async call so that the test doesn't end before the call ofnew Timer(...)
finishes.You can additionally add provide how often (min/max) the method has to be called to satisfy the test. If your tested functionality calls a method with more than one parameter you use `expectAsync2)
The mistake in your referenced question was, that your call to
expectAsyncX
was delayed too. The call toexpectAsyncX
has to be made before the async functionality is invoked to register which method has to be called.You can check what happens if you set
count
andmax
to3
.You can have a look at the Asynchronous tests section of the article Unit Testing with Dart.