Added 'exclude' parameter to 'testWidgets()'. (#86397)
This commit is contained in:
parent
fd3e03c5df
commit
eb62bce924
@ -100,6 +100,14 @@ typedef WidgetTesterCallback = Future<void> Function(WidgetTester widgetTester);
|
||||
/// each value of the [TestVariant.values]. If [variant] is not set, the test
|
||||
/// will be run once using the base test environment.
|
||||
///
|
||||
/// If either [exclude] or [skip] is `true`, then the test will be skipped. The
|
||||
/// difference is that [skip] is a temporary way to disable a problematic test
|
||||
/// while a fix is being developed. It should have a comment after it with a
|
||||
/// link to a tracking issue for the work on re-enabling the test.
|
||||
///
|
||||
/// [exclude] is used to indicate that the test is not designed to run under
|
||||
/// the condition given and should always be skipped when it is `true`.
|
||||
///
|
||||
/// If the [tags] are passed, they declare user-defined tags that are implemented by
|
||||
/// the `test` package.
|
||||
///
|
||||
@ -117,11 +125,26 @@ typedef WidgetTesterCallback = Future<void> Function(WidgetTester widgetTester);
|
||||
/// expect(find.text('Success'), findsOneWidget);
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
/// ### Excluded test
|
||||
/// ```dart
|
||||
/// testWidgets('Some test that will never make sense for the web', (WidgetTester tester) async {
|
||||
/// // test code
|
||||
/// }, exclude: isBrowser);
|
||||
/// ```
|
||||
///
|
||||
/// ### Skipped test
|
||||
/// ```dart
|
||||
/// testWidgets('Some flaky test', (WidgetTester tester) async {
|
||||
/// // test code
|
||||
/// }, skip: true); // https://github.com/flutter/flutter/issues/12345
|
||||
/// ```
|
||||
@isTest
|
||||
void testWidgets(
|
||||
String description,
|
||||
WidgetTesterCallback callback, {
|
||||
bool? skip,
|
||||
bool skip = false,
|
||||
bool exclude = false,
|
||||
test_package.Timeout? timeout,
|
||||
Duration? initialTimeout,
|
||||
bool semanticsEnabled = true,
|
||||
@ -169,7 +192,7 @@ void testWidgets(
|
||||
timeout: initialTimeout,
|
||||
);
|
||||
},
|
||||
skip: skip,
|
||||
skip: (exclude || skip) ? true : null,
|
||||
timeout: timeout ?? binding.defaultTestTimeout,
|
||||
tags: tags,
|
||||
);
|
||||
|
@ -738,6 +738,16 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('Skip and exclude work', () {
|
||||
testWidgets('skipping a test skips it', (WidgetTester tester) async {
|
||||
expect(true, false); // shouldn't get here
|
||||
}, skip: true); // https://github.com/someissue
|
||||
|
||||
testWidgets('excluding a test skips it', (WidgetTester tester) async {
|
||||
expect(true, false); // shouldn't get here
|
||||
}, exclude: true);
|
||||
});
|
||||
|
||||
group('Pending timer', () {
|
||||
late TestExceptionReporter currentExceptionReporter;
|
||||
setUp(() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user