Skip to content
pubscout

build_test

3.5.23, released 5 weeks ago by tools.dart.dev

Utilities for unit testing Dart build_runner builders in memory

$ flutter pub add build_test
Source repository

What it does

Provides helper functions to run builders in RAM, resolve source code, and read generated assets. It supports in-memory builds, real source files, and asset resolution via analyzer.

AI-written summary of version 3.5.23, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Testing custom build_runner builders
  • Running small isolated build tests
  • Need to resolve Dart source during tests
  • Reading generated code as strings

Skip it when

  • Production code that needs to run on device or web
  • When you only need to generate code without testing

Strengths

  • Runs builds entirely in memory, fast and isolated
  • Supports real source files via TestReaderWriter
  • Built-in helpers for resolving source code with analyzer
  • Easy to read generated assets as strings

Weaknesses

  • Only works with build_runner; not for general code generation
  • Requires Dart 3.11+ and specific build_runner versions
  • Limited to builder testing, not general utilities

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
15

Add dependency, import build_test, call testBuilder or testBuilders; no extra permissions needed

```dart
import 'package:build_test/build_test.dart';

void main() {
  testBuilder(myBuilder, {
    'test_package|lib/a.dart': '''
      class TestClass {}
    '''
  });
}
```

Alternatives

Packages that do the same job and could replace build_test.

  • golden_test

    A zero-dependency wrapper for Flutter golden tests with theme, locale, and multi-device support.

  • patrol_log

    Log package for Patrol, a Flutter-native UI testing framework

  • very_good_test_runner

    A Dart/Flutter test runner that streams TestEvent objects from dart test or flutter test.

  • flame_test

    Classes and helpers for testing applications built with the Flame Engine.

Works with

Packages commonly used together with build_test: ones it builds on, ones built on it, and its own family.