build_test 0.6.4 copy "build_test: ^0.6.4" to clipboard
build_test: ^0.6.4 copied to clipboard

outdatedDart 1 only

Utilities for writing unit tests of Builders.

build_test #

Testing utilities for users of package:build.
Build Status Issues related to build_test Pub Package Version Latest Dartdocs Join the chat on Gitter

Installation #

This package is intended to only be as a development dependency for users of package:build, and should not be used in any production code. Simply add to your pubspec.yaml:

dev_dependencies:
  build_test:

Usage #

See the test folder in the build package for more examples.

Resolve source code for testing #

Using resolveAsset and resolveSource, you can resolve Dart source code into a static element model, suitable for probing and using within tests of code you might have written for a Builder:

test('should resolve a simple dart file', () async {
  var resolver = await resolveSource(r'''
    library example;

    class Foo {}
  ''');
  var libExample = resolver.getLibraryByName('example');
  expect(libExample.getType('Foo'), isNotNull);
});

Run a Builder within a test environment #

Using testBuilder, you can run a functional test of a Builder, including feeding specific assets, and more. It automatically creates an in-memory representation of various utility classes.

Various test implementations of classes #