diff --git a/packages/flutter/test/scheduler/benchmarks_test.dart b/packages/flutter/test/scheduler/benchmarks_test.dart index 4539a8fad3..70472b7ff6 100644 --- a/packages/flutter/test/scheduler/benchmarks_test.dart +++ b/packages/flutter/test/scheduler/benchmarks_test.dart @@ -63,6 +63,9 @@ Future main() async { expect(endFramesBegun, equals(startFramesBegun + 1)); expect(endFramesDrawn, equals(startFramesDrawn + 1)); - }); + }, + // We are not interested in the performance of the "benchmark", we are just + // testing the behavior. So it's OK that asserts are enabled. + mayRunWithAsserts: true); }); } diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index 45142cf533..0000f91131 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -133,8 +133,10 @@ void testWidgets( /// If the callback is asynchronous, make sure you `await` the call /// to [benchmarkWidgets], otherwise it won't run! /// -/// Benchmarks must not be run in checked mode. To avoid this, this -/// function will print a big message if it is run in checked mode. +/// Benchmarks must not be run in checked mode, because the performance is not +/// representative. To avoid this, this function will print a big message if it +/// is run in checked mode. Unit tests of this method pass `mayRunWithAsserts`, +/// but it should not be used for actual benchmarking. /// /// Example: /// @@ -152,8 +154,11 @@ void testWidgets( /// }); /// exit(0); /// } -Future benchmarkWidgets(WidgetTesterCallback callback) { +Future benchmarkWidgets(WidgetTesterCallback callback, {bool mayRunWithAsserts = false}) { assert(() { + if (mayRunWithAsserts) + return true; + print('┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓'); print('┇ ⚠ THIS BENCHMARK IS BEING RUN WITH ASSERTS ENABLED ⚠ ┇'); print('┡╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┦');