Use a more consistent wait-for-callbacks pattern (#1270)

There are two guarantees in play around outstanding callbacks:
-  `tearDown` callbacks are not called until after outstanding callbacks
   from the test body are complete.
-  The overall test is not considered complete until after outstanding
   callbacks from `tearDown` callbacks are also complete.

Previously these two guarantees were split in two locations. In
`Declarer` the setups and test body are wrapped with
`Invoker.waitForOutstandingCallbacks` to handle the first guarantee. In
`Invoker` a _separate_ outstanding callbacks counter wraps the zone
where the setups and test body are run, and it only counts the
callbacks from the teardown callbacks. It is immediately awaited after
spawning the future that runs the entire case - setups, test body, and
teardowns.

Now the two guarantees are handled together in sequence with a pattern
that matches the intent - there are two calls to
`waitForOutstandingCallbacks` so that both guarantees are clear.

- Remove the call to `waitForOutstandingCallbacks` in `Declarer`.
- Remove the wrapping in `Future` in `Invoker`. Since we immediately
  awaited the async counter the only thing that the Future wrapping was
  accomplishing was to delay the start of the test body - this is now
  accomplished with `await Future(() {});`.
- Use two calls to `waitForOutstandingCallbacks` instead of wrapping a
  different levels - remove the counter zone key from the surrounding
  zone.
2 files changed
tree: 2b20f02942834c06bf692a9c13f433145978f305
  1. pkgs/
  2. tool/
  3. .gitignore
  4. .travis.yml
  5. analysis_options.yaml
  6. CONTRIBUTING.md
  7. mono_repo.yaml
  8. README.md
README.md

Test Mono Repository

This repository contains packages for writing and running Dart tests.

test

A full featured packaged for writing and running Dart tests on various platforms, e.g. VM, Chrome, Node etc.

test_api

A minimal package for writing tests. This package is used by package:test and package:test_core.

test_core

A minimal package for writing and running tests. It also contains extensions for implementing a custom test runner. This package is used by package:test.