A test bench for Dart.

Build Status


Declare Test Libraries.

// The TestGroup annotation is optional.
@TestGroup('Console', runs: const ['a', 'b'])
library bench.example.console;

Declare Setup and Teardown Functions.

// The @Setup function is optional; there may be 0 or 1 per test library.
// The TestRun argument is optional; it carries context based on @TestGroup.
setup(TestRun run) {
  if ( == 'a') {
    print('Setup is invoked one time before each test.');
  } else {
    print('And it can do different work each time the test group runs!');

// The @Teardown function is optional; there may be 0 or 1 per test library. 
// The optional TestRun argument may also be received here.
teardown() => print('Teardown is invoked one time after each test');

Declare Test Functions.

@Test('An example test case that passes.')
void testPass() {
  expect(true, isTrue);

void testError() {
  throw new StateError('snarf');

testAsyncError() {
  return new Future.delayed(const Duration(milliseconds: 100), () {
    throw new UnimplementedError();    

@Test('Known to fail.')
testSkipKnownFailure() {
  expect(false, isTrue);  

Reflect and Run Tests.

import 'package:bench/bench.dart';

// TODO: import your test libraries here so that reflection can find them.

// You may also add a `main` to a test library so that it may be run standalone!
void main() => reflectTests();

Bench uses the MIT license as described in the LICENSE file, and follows semantic versioning.