Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Flutter Test ArchitectNew to Visual Studio Code? Get it now.
Flutter Test Architect

Flutter Test Architect

Emre Y

|
1 install
| (0) | Free
Recognises any Flutter project with the Dart analyzer (bloc, riverpod, provider, clean architecture, feature-first) and generates tests that fit it: bloc_test + mocktail, repository success/error/timeout, JSON round trips and widget tests.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Flutter Test Architect

Türkçe

Open any Flutter project (it does not need to be built with Flutter Architect) and get a project map: the architecture it uses, its features and layers, every Bloc/Cubit, notifier, repository, model, page and route, and which of them already have tests. Right-click a class and generate a test that fits the project: bloc_test + mocktail for Blocs, success/error/timeout scenarios for repositories, JSON round trips for models and widget tests with a fake Cubit for pages.

The generated tests are meant to pass on the first flutter test. The repository's CI generates a test for every class of four sample projects (bloc + clean architecture, Riverpod + freezed, provider, plain setState) and runs them.

How it reads your project

Source What it gives
pubspec.yaml (+ pubspec.lock) State management (flutter_bloc, riverpod, provider, get), DI (get_it, injectable), network (dio, http), routing (go_router, auto_route), models (freezed, json_serializable), test packages already present (bloc_test, mocktail, mockito, patrol)
Folder layout Feature-first (lib/features/*, lib/modules/*), clean-architecture layers (data / domain / presentation), layered by type (models, screens, …) or flat
Dart analyzer Classes, constructors and their dependencies, method bodies (which collaborator methods are called, emit(...) calls and whether they sit in try or catch), JSON keys read in fromJson, providers, GoRoutes / MaterialApp.routes / @RoutePage
.flutter_architect/config.json Used when present (architecture, state management, network, routing, model generation)

Classes are read with package:analyzer — not with regular expressions — through a small Dart helper that ships with the extension and runs on your own Flutter SDK. It parses syntax only, so the project does not need pub get or code generation to be mapped. The first run prepares the helper once (dart pub get + a kernel snapshot in VS Code's global storage); later runs take about a second.

Project map

The Flutter Test Architect activity bar view shows:

  • Architecture — structure, state management, DI, network, routing, model style and test packages.
  • Features (or layers for non-feature projects) → State / Data / Models / UI → classes. Green check: a test exists. Hollow circle: no test yet.
  • Routes — path → page, with the page's test status.

Click a class to open it. Inline actions: Generate test, Open test, Run test. Right-click a feature or layer: Generate missing tests. The map refreshes when you save a Dart file, pubspec.yaml or the Flutter Architect config.

Generating tests

Right-click a Dart file under lib/ (editor or explorer), use the tree, or run Flutter Test Architect: Generate Test. With several classes in a file you pick one (the class under the cursor is preselected). The test goes to test/ mirroring lib/, named after the class (test/features/todos/presentation/cubit/todos_cubit_test.dart).

Class Generated test
Cubit / Bloc Initial state from the super(...) call; per public method (Cubit) or per event (Bloc): a success and an error scenario. Emitted states are read from the emit(...) calls on that path; state.copyWith(status: X.loading) becomes isA<State>().having((s) => s.status, 'status', X.loading). Collaborators are mocked and verified. Where states depend on runtime values the test verifies interactions and leaves a TODO.
Repository / service / data source For each public async method: success, server error and timeout. Dio: a fake HttpClientAdapter (also checks the HTTP verb); package:http: MockClient; other collaborators (a data source, an API client): mocks. The response JSON is built from the model's fromJson, including wrappers such as response.data['user']. Whether an error should be thrown or handled is decided from the method's try/catch.
Model (fromJson/toJson, json_serializable, freezed) fromJson with sample JSON (honours fieldRename, @JsonKey(name:), @JsonValue, @Default, enums, dates, nested models) and field checks; toJson → fromJson round trip; equality after the round trip when the class has value equality.
Value object (Equatable / ==) Equal values are equal with the same hashCode; a changed field is not equal.
Riverpod notifier ProviderContainer with repository providers overridden by mocks (retry disabled on Riverpod 3); build success/error, every method, AsyncValue.guard errors.
ChangeNotifier / GetX controller Every method: listeners notified, collaborators called, errors handled or reported.
Page / widget Pumped in MaterialApp. Cubits/Blocs it reads become MockCubit/MockBloc with whenListen (and are registered in GetIt.instance when the page looks them up with getIt<X>()); Riverpod notifiers are overridden with fakes returning sample data; provider ChangeNotifiers are real with mocked collaborators. One extra test per sealed state subclass or per value of an enum status field.

dev_dependencies

Before writing a test that needs a package the project lacks (mocktail, bloc_test), the extension lists them and asks:

  • Add and generate runs flutter pub add --dev … in the project.
  • Generate without new packages writes hand-written noSuchMethod fakes and plain flutter_test tests instead (no bloc_test).

Set flutterTestArchitect.mockStyle to fakes to never use mocktail.

Settings

Setting Default
flutterTestArchitect.flutterSdkPath "" Flutter SDK folder. Empty: dart.flutterSdkPath, FLUTTER_ROOT, PATH, common install folders.
flutterTestArchitect.mockStyle auto auto (mocktail, asks first), mocktail, fakes.
flutterTestArchitect.refreshOnSave true Re-analyze on save.

Privacy

Everything runs locally with your Flutter SDK. The only network access is dart pub get for the helper on first use and the flutter pub add you approve. No code leaves your machine.

Limitations

  • Expectations come from static analysis. Methods whose states depend on runtime values get interaction checks and a TODO instead of guessed states — review generated tests like any other code.
  • Mocks use mocktail (or package-free fakes). Projects that only use mockito get mocktail tests.
  • json_serializable options set globally in build.yaml (e.g. field_rename) are not read; class-level @JsonSerializable(...) is.
  • Riverpod family providers and StreamNotifiers get basic tests only.
  • The analyzer helper supports package:analyzer 6.x – 13.x (Dart 3.0+).

Roadmap

End-to-end scenarios (Patrol/Maestro), a scenario catalogue (.devorbit/scenarios.yaml) and a workflow_dispatch workflow so DevOrbit's Test section can run selected scenarios remotely: see docs/DEVORBIT-TEST-DESIGN.md.

Development

npm install
npm test                 # typecheck, lint, build, unit tests
npm run test:integration # extension inside VS Code against samples/
npm run test:flutter     # generate tests for every sample class and run flutter test
FTA_MODE=fakes npm run test:flutter
npm run outlines         # refresh test/fixtures/outlines from samples/

Press F5 to start an Extension Development Host with samples/bloc_clean_app (or all samples) open.

samples/ holds four small apps used by the tests: bloc_clean_app (feature-first + clean architecture, flutter_bloc, get_it, Dio, go_router, json_serializable), riverpod_app (Riverpod 3, freezed, http), provider_app (provider, http, feature folders) and plain_app (setState, http, flat).

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft