Skip to content

A widget test harness (pumpWidget, tap, find) that runs under dn test #109

Backlog

Description

@tayormi

Select your plan

Standard - priority support

Confirmations

  • I searched the existing feature requests and this is not a duplicate.

Framework or plugin?

Framework

Platform

Not platform-specific

Use case

We can't test any widget code on the host. dn test refuses flutter_test, flutter_driver and integration_test (kUnavailableTestLibraries in packages/flutter_tools/lib/src/dart/pubspec_sdk_entries.dart), and only package:test runs. Under dn test the framework is the stub package, where every body throws UnimplementedError, so no State, build, layout or navigation code can run either, and plugins don't load.

So a screen's behaviour (which widget a state shows, what a tap does, what is pushed) can only be checked by running the app on a simulator and driving it from outside, which is slow (minutes per journey) and can't run in CI without a Mac and a simulator. Today we move as much logic as we can into plain Dart functions tested with package:test, and drive the rest on the simulator. Nothing on dartpub.dev fills this gap, because it needs the framework itself to run on the host.

Proposal

A dartnative_test package, or flutter_test-compatible entry points, that run the real framework on the host with a fake native side: a headless reconciler that records the native mutations and computes layout, plus fake platform bindings so plugins can be stubbed.

import 'package:dartnative_test/dartnative_test.dart';

void main() {
  testWidgets('tapping Open pushes the detail page', (tester) async {
    await tester.pumpWidget(const App(home: Home()));
    await tester.tap(find.text('Open'));
    await tester.pumpAndSettle();
    expect(find.byType(Detail), findsOneWidget);
  });
}

The minimum useful set is pumpWidget, pump(duration), pumpAndSettle, tap, enterText, find.text / find.byType / find.byKey, and a way to register a fake for a plugin's binding.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions