| commit | 0b08d704c2a314d8446a30de75906e7991c6f21b | [log] [tgz] |
|---|---|---|
| author | Nate Bosch <nbosch@google.com> | Wed Mar 08 11:22:22 2023 -0800 |
| committer | GitHub <noreply@github.com> | Wed Mar 08 11:22:22 2023 -0800 |
| tree | 181c2269582b1e36a2e9ec7b10966e3941ce44aa | |
| parent | aacee2c7f722494dbbcb5ce7576b9b63b33a6217 [diff] |
Add a hooks_testing library (#1952) Previous test for methods like `expect`, `expectLater`, and `expectAsync` used internal details of the test runner like `LiveTest` to check behaviors such as holding the test open and specific failure behavior. Add an abstraction `TestCaseMonitor` to hide the implementation details of creating and running a `LocalTest`. Expose only the parts of `LiveTest` which are used by current tests - the state and errors. The new class is defined in a new library `hooks_testing` since it is intended primarily for writing tests for code that uses the `hooks` library. Add a new `State` enum to hide some details of `LiveTest`. There is already a class named `State` that holds the `Status` and `Result` for a `LiveTest`. This `State` attempts to encode the useful parts of the status and result into a single enum. We don't get much use out of the separate status and result. The `Result` is always `passed` when the `Status` is anything other than `complete` (it shouldn't be read), and changing the `Result` to anything else is _always_ accompanied by setting the `status` to `complete`. The new enum also lets us hide the `failure` and `error` distinction instead of adding new dependencies to it. This works towards #1465 Migrate tests under `test_api/test/frontend` for the tests which will be migrating to `package:matcher` to use the new APIs. Move to a `utils_new.dart` file which will be moved along with these tests, and the old `utils.dart` file will remain for testing the scaffolding APIs. Do not replace the `expectTestsBlock` utility, the usage of this utility is not any more clear or readable than spelling out the full behavior in the test. Add tests in `checks` for the behavior of holding the test for pending work, and for unawaited failures. Add utilities for testing against a `TestMonitor` locally within the test.
Welcome! package:test is the standard testing library for Dart and Flutter. If you have questions about Dart testing, please see the docs for package:test. package:test_api and package:test_core are implementation details and generally not user-facing.
package:checks is a relatively new library for expressing test expectations. It's a more modern version of package:matcher and features a literate API.
| Package | Description | Version |
|---|---|---|
| checks | A framework for checking values against expectations and building custom expectations. | |
| test | A full featured library for writing and running Dart tests across platforms. | |
| test_api | ||
| test_core |