-
Notifications
You must be signed in to change notification settings - Fork 218
Add an API to do some customization and then directly run tests in process #1310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We want to explore a bit on #1311 before making decisions about making more of this stuff public and spreading use. |
Another thing to consider here is whether and how we can support coverage. @grouma - do you know if it is feasible to enable coverage collection from within the isolate? |
Not sure what you mean by "within the isolate". However, |
Another approach to consider here, we could also have an API that accepts |
Towards #1310 Open questions: - Can we make coverage work? How? - This currently prints full stack traces on failure. Is that OK? Do we need to install a top-level zone with an uncaught error handler to truncate them?
Took a bit more look at the idea of handling this with |
Towards #1310, #1328 Add `directRunTest` to configure a reporter and run tests directly in the same isolate. Add `enumerateTestCases` to collect test names without running them, and `directRunSingleTest` to run a specific test by its full name. These APIs ensure the uniqueness of test names to avoid ambiguity. This restriction may be spread to tests run through the normal test runner as well. - Add `fullTestName` option on `Declarer`. When used, only the test (or tests if uniqueness is not checked separately) will be considered as a test case. - Add `directRunTest`, `enumerateTestCases`, and `directRunSingleTest` APIs. These are kept under a `lib/src/` import for now, and any other package that uses these APIs should pin to a specific version of `package:test_core`. The details of these APIs might change without a major version bump.
Background
Most of our runners assume some separation between the process that orchestrates running all the tests, and the tests themselves. This is different Isolates in the VM case, and external processes like browsers in other cases.
We also support running a
_test.dart
file directly:test/pkgs/test_core/lib/test_core.dart
Lines 34 to 72 in 1c29a64
This support is hardcoded to the
expanded
reporter and does not take any arguments for things like test filters.In all cases when we run tests through a runner (internally, flutter_test, build_test, and
package:test
runner) we "wrap" the users library with out own and forward to theirmain
in some way where the details vary by platform.Goal
We should make it easier to combine the concepts of running without an external runner doing the orchestration, along with allowing some customization beyond the defaults. The immediate need is to register and pick a custom reporter.
Plan
Add a function in
package:test_core/backend.dart
likeFuture<bool> runTests(FutureOr<void> Function() userMain, {ReporterDetails reporter})
.Then platforms that want to build a custom "runner" that is baked in to a single execution instead of having a separate orchestration would use it by generating a wrapping library like:
We'd start with
ReporterDetails
for now, and we can hopefully add other named arguments for other customizations that crop up. For instance we might support test filtering by tag with an additional named argument.The text was updated successfully, but these errors were encountered: