flutter_test.dart 3.18 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
Adam Barth's avatar
Adam Barth committed
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
/// Testing library for flutter, built on top of `package:test`.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
///
/// ## Test Configuration
///
/// The testing library exposes a few constructs by which projects may configure
/// their tests.
///
/// ### Per test or per file
///
/// Due to its use of `package:test` as a foundation, the testing library
/// allows for tests to be initialized using the existing constructs found in
/// `package:test`. These include the [setUp] and [setUpAll] methods.
///
/// ### Per directory hierarchy
///
/// In addition to the constructs provided by `package:test`, this library
/// supports the configuration of tests at the directory level.
///
/// Before a test file is executed, the Flutter test framework will scan up the
/// directory hierarchy, starting from the directory in which the test file
/// resides, looking for a file named `flutter_test_config.dart`. If it finds
/// such a configuration file, the file will be assumed to have a `main` method
/// with the following signature:
///
/// ```dart
30
/// Future<void> testExecutable(FutureOr<void> Function() testMain);
31 32 33 34 35 36 37 38 39 40 41 42 43 44
/// ```
///
/// The test framework will execute that method and pass it the `main()` method
/// of the test. It is then the responsibility of the configuration file's
/// `main()` method to invoke the test's `main()` method.
///
/// After the test framework finds a configuration file, it will stop scanning
/// the directory hierarchy. In other words, the test configuration file that
/// lives closest to the test file will be selected, and all other test
/// configuration files will be ignored. Likewise, it will stop scanning the
/// directory hierarchy when it finds a `pubspec.yaml`, since that signals the
/// root of the project.
///
/// If no configuration file is located, the test will be executed like normal.
45 46 47 48 49 50 51 52 53
///
/// See also:
///
///  * [WidgetController.hitTestWarningShouldBeFatal], which can be set
///    in a `flutter_test_config.dart` file to turn warnings printed by
///    [WidgetTester.tap] and similar APIs into fatal errors.
///  * [debugCheckIntrinsicSizes], which can be set in a
///    `flutter_test_config.dart` file to enable deeper [RenderBox]
///    tests of the intrinsic APIs automatically while laying out widgets.
Adam Barth's avatar
Adam Barth committed
54 55
library flutter_test;

56 57
export 'dart:async' show Future;

58
export 'src/_goldens_io.dart' if (dart.library.html) 'src/_goldens_web.dart';
59
export 'src/accessibility.dart';
60
export 'src/all_elements.dart';
61
export 'src/animation_sheet.dart';
62
export 'src/binding.dart';
63
export 'src/controller.dart';
64
export 'src/event_simulation.dart';
65
export 'src/finders.dart';
66
export 'src/frame_timing_summarizer.dart';
67
export 'src/goldens.dart';
68
export 'src/image.dart';
69
export 'src/matchers.dart';
70
export 'src/nonconst.dart';
71
export 'src/platform.dart';
72
export 'src/restoration.dart';
73
export 'src/stack_manipulation.dart';
74
export 'src/test_async_utils.dart';
75
export 'src/test_compat.dart';
76
export 'src/test_exception_reporter.dart';
Adam Barth's avatar
Adam Barth committed
77
export 'src/test_pointer.dart';
78
export 'src/test_text_input.dart';
79
export 'src/test_vsync.dart';
Adam Barth's avatar
Adam Barth committed
80
export 'src/widget_tester.dart';
81
export 'src/window.dart';