How can one test a method that returns Future before the test runner completes? I have a problem where my unit test runner completes before the asynchronous methods are completed.
How can one test a method that returns Future before the test runner completes?
Share
Full example of how to test with the
completionmatcher is as follows.The unit test runner might not complete before this code completes. So it would seem that the unit test executed correctly. With
Futures that might take longer periods of time to complete the proper way is to utilizecompletionmatcher available in unittest package.One would be tempted to do the following which would be incorrect way of unit testing a returned Future in dart. WARNING: below is an incorrect way to test Futures.