fix(#231): Exposed `frameBindingPolicy` on the test runner when running tests which can affect how frames are painted and the speed of the test run, I've removed the default value which might be responsible for #231
This commit is contained in:
parent
66919d6539
commit
b73da409b3
|
@ -1,3 +1,6 @@
|
||||||
|
## [3.0.0-rc.15] - 28/06/2022
|
||||||
|
- Exposed `frameBindingPolicy` on the test runner when running tests which can affect how frames are painted and the speed of the test run, I've removed the default value which might be responsible for #231
|
||||||
|
|
||||||
## [3.0.0-rc.14] - 28/06/2022
|
## [3.0.0-rc.14] - 28/06/2022
|
||||||
- Fix #237 - Ensure everything works on the web
|
- Fix #237 - Ensure everything works on the web
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter_gherkin/flutter_gherkin.dart';
|
||||||
import 'package:flutter_simple_dependency_injection/injector.dart';
|
import 'package:flutter_simple_dependency_injection/injector.dart';
|
||||||
import 'package:gherkin/gherkin.dart';
|
import 'package:gherkin/gherkin.dart';
|
||||||
|
|
||||||
|
import 'hooks/attach_screenshot_after_step_hook.dart';
|
||||||
import 'hooks/reset_app_hook.dart';
|
import 'hooks/reset_app_hook.dart';
|
||||||
import 'steps/expect_todos_step.dart';
|
import 'steps/expect_todos_step.dart';
|
||||||
import 'steps/multiline_string_with_formatted_json.dart';
|
import 'steps/multiline_string_with_formatted_json.dart';
|
||||||
|
@ -22,7 +23,7 @@ FlutterTestConfiguration gherkinTestConfiguration = FlutterTestConfiguration(
|
||||||
],
|
],
|
||||||
hooks: [
|
hooks: [
|
||||||
ResetAppHook(),
|
ResetAppHook(),
|
||||||
// AttachScreenshotAfterStepHook(),
|
AttachScreenshotAfterStepHook(),
|
||||||
],
|
],
|
||||||
reporters: [
|
reporters: [
|
||||||
StdoutReporter(MessageLevel.error)
|
StdoutReporter(MessageLevel.error)
|
||||||
|
|
|
@ -12,11 +12,13 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
|
||||||
required StartAppFn appMainFunction,
|
required StartAppFn appMainFunction,
|
||||||
required Timeout scenarioExecutionTimeout,
|
required Timeout scenarioExecutionTimeout,
|
||||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||||
|
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||||
}) : super(
|
}) : super(
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
appMainFunction: appMainFunction,
|
appMainFunction: appMainFunction,
|
||||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||||
|
framePolicy: framePolicy,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -389,11 +391,13 @@ void executeTestSuite({
|
||||||
required StartAppFn appMainFunction,
|
required StartAppFn appMainFunction,
|
||||||
Timeout scenarioExecutionTimeout = const Timeout(Duration(minutes: 10)),
|
Timeout scenarioExecutionTimeout = const Timeout(Duration(minutes: 10)),
|
||||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||||
|
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||||
}) {
|
}) {
|
||||||
_CustomGherkinIntegrationTestRunner(
|
_CustomGherkinIntegrationTestRunner(
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
appMainFunction: appMainFunction,
|
appMainFunction: appMainFunction,
|
||||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||||
|
framePolicy: framePolicy,
|
||||||
).run();
|
).run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "3.0.0-rc.13"
|
version: "3.0.0-rc.14"
|
||||||
flutter_simple_dependency_injection:
|
flutter_simple_dependency_injection:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -64,7 +64,7 @@ Future<void> writeGherkinReports(List<dynamic> reports) async {
|
||||||
File file = File(
|
File file = File(
|
||||||
'${integration_test_driver.testOutputsDirectory}/'
|
'${integration_test_driver.testOutputsDirectory}/'
|
||||||
'$filenamePrefix'
|
'$filenamePrefix'
|
||||||
'v${i + 1}.json',
|
'-v${i + 1}.json',
|
||||||
);
|
);
|
||||||
|
|
||||||
await file.writeAsString(json.encode(reportData));
|
await file.writeAsString(json.encode(reportData));
|
||||||
|
|
|
@ -25,11 +25,13 @@ class WidgetTesterAppDriverAdapter
|
||||||
Duration? duration = const Duration(milliseconds: 100),
|
Duration? duration = const Duration(milliseconds: 100),
|
||||||
Duration? timeout = const Duration(seconds: 30),
|
Duration? timeout = const Duration(seconds: 30),
|
||||||
}) async {
|
}) async {
|
||||||
return _implicitWait(
|
final result = await _implicitWait(
|
||||||
duration: duration,
|
duration: duration,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
force: true,
|
force: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> _implicitWait({
|
Future<int> _implicitWait({
|
||||||
|
@ -39,11 +41,13 @@ class WidgetTesterAppDriverAdapter
|
||||||
}) async {
|
}) async {
|
||||||
if (waitImplicitlyAfterAction || force == true) {
|
if (waitImplicitlyAfterAction || force == true) {
|
||||||
try {
|
try {
|
||||||
return await nativeDriver.pumpAndSettle(
|
final result = await nativeDriver.pumpAndSettle(
|
||||||
duration ?? const Duration(milliseconds: 100),
|
duration ?? const Duration(milliseconds: 100),
|
||||||
EnginePhase.sendSemanticsUpdate,
|
EnginePhase.sendSemanticsUpdate,
|
||||||
timeout ?? const Duration(seconds: 30),
|
timeout ?? const Duration(seconds: 30),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +72,7 @@ class WidgetTesterAppDriverAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<int>> screenshotOnAndroid() {
|
Future<List<int>> screenshotOnAndroid() async {
|
||||||
RenderObject? renderObject = binding.renderViewElement?.renderObject;
|
RenderObject? renderObject = binding.renderViewElement?.renderObject;
|
||||||
if (renderObject != null) {
|
if (renderObject != null) {
|
||||||
while (!renderObject!.isRepaintBoundary) {
|
while (!renderObject!.isRepaintBoundary) {
|
||||||
|
@ -76,9 +80,13 @@ class WidgetTesterAppDriverAdapter
|
||||||
assert(renderObject != null);
|
assert(renderObject != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (renderObject.debugNeedsPaint) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
}
|
||||||
|
|
||||||
final layer = renderObject.debugLayer as OffsetLayer;
|
final layer = renderObject.debugLayer as OffsetLayer;
|
||||||
|
|
||||||
return layer
|
return await layer
|
||||||
.toImage(renderObject.paintBounds)
|
.toImage(renderObject.paintBounds)
|
||||||
.then((value) => value.toByteData(format: ui.ImageByteFormat.png))
|
.then((value) => value.toByteData(format: ui.ImageByteFormat.png))
|
||||||
.then((value) => value!.buffer.asUint8List());
|
.then((value) => value!.buffer.asUint8List());
|
||||||
|
@ -105,7 +113,7 @@ class WidgetTesterAppDriverAdapter
|
||||||
|
|
||||||
return await screenshotOnAndroid();
|
return await screenshotOnAndroid();
|
||||||
} else {
|
} else {
|
||||||
return binding.takeScreenshot(name);
|
return await binding.takeScreenshot(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,11 +34,13 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
|
||||||
required StartAppFn appMainFunction,
|
required StartAppFn appMainFunction,
|
||||||
required Timeout scenarioExecutionTimeout,
|
required Timeout scenarioExecutionTimeout,
|
||||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||||
|
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||||
}) : super(
|
}) : super(
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
appMainFunction: appMainFunction,
|
appMainFunction: appMainFunction,
|
||||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||||
|
framePolicy: framePolicy,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -54,12 +56,14 @@ void executeTestSuite({
|
||||||
required StartAppFn appMainFunction,
|
required StartAppFn appMainFunction,
|
||||||
Timeout scenarioExecutionTimeout = const Timeout(const Duration(minutes: 10)),
|
Timeout scenarioExecutionTimeout = const Timeout(const Duration(minutes: 10)),
|
||||||
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
|
||||||
|
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
|
||||||
}) {
|
}) {
|
||||||
_CustomGherkinIntegrationTestRunner(
|
_CustomGherkinIntegrationTestRunner(
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
appMainFunction: appMainFunction,
|
appMainFunction: appMainFunction,
|
||||||
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
appLifecyclePumpHandler: appLifecyclePumpHandler,
|
||||||
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
scenarioExecutionTimeout: scenarioExecutionTimeout,
|
||||||
|
framePolicy: framePolicy,
|
||||||
).run();
|
).run();
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
|
|
@ -38,6 +38,7 @@ abstract class GherkinIntegrationTestRunner {
|
||||||
final StartAppFn appMainFunction;
|
final StartAppFn appMainFunction;
|
||||||
final AppLifecyclePumpHandlerFn? appLifecyclePumpHandler;
|
final AppLifecyclePumpHandlerFn? appLifecyclePumpHandler;
|
||||||
final Timeout scenarioExecutionTimeout;
|
final Timeout scenarioExecutionTimeout;
|
||||||
|
final LiveTestWidgetsFlutterBindingFramePolicy? framePolicy;
|
||||||
final AggregatedReporter _reporter = AggregatedReporter();
|
final AggregatedReporter _reporter = AggregatedReporter();
|
||||||
|
|
||||||
late final Iterable<ExecutableStep>? _executableSteps;
|
late final Iterable<ExecutableStep>? _executableSteps;
|
||||||
|
@ -47,7 +48,6 @@ abstract class GherkinIntegrationTestRunner {
|
||||||
|
|
||||||
AggregatedReporter get reporter => _reporter;
|
AggregatedReporter get reporter => _reporter;
|
||||||
Hook get hook => _hook!;
|
Hook get hook => _hook!;
|
||||||
LiveTestWidgetsFlutterBindingFramePolicy? get framePolicy => null;
|
|
||||||
|
|
||||||
/// A Gherkin test runner that uses [WidgetTester] to instrument the app under test.
|
/// A Gherkin test runner that uses [WidgetTester] to instrument the app under test.
|
||||||
///
|
///
|
||||||
|
@ -64,6 +64,7 @@ abstract class GherkinIntegrationTestRunner {
|
||||||
required this.appMainFunction,
|
required this.appMainFunction,
|
||||||
required this.scenarioExecutionTimeout,
|
required this.scenarioExecutionTimeout,
|
||||||
this.appLifecyclePumpHandler,
|
this.appLifecyclePumpHandler,
|
||||||
|
this.framePolicy,
|
||||||
}) {
|
}) {
|
||||||
configuration.prepare();
|
configuration.prepare();
|
||||||
_registerReporters(configuration.reporters);
|
_registerReporters(configuration.reporters);
|
||||||
|
@ -79,8 +80,7 @@ abstract class GherkinIntegrationTestRunner {
|
||||||
Future<void> run() async {
|
Future<void> run() async {
|
||||||
_binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
_binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
_binding.framePolicy =
|
_binding.framePolicy = framePolicy ?? _binding.framePolicy;
|
||||||
framePolicy ?? LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
|
|
||||||
|
|
||||||
tearDownAll(
|
tearDownAll(
|
||||||
() {
|
() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_gherkin
|
name: flutter_gherkin
|
||||||
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
|
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
|
||||||
version: 3.0.0-rc.14
|
version: 3.0.0-rc.15
|
||||||
homepage: https://github.com/jonsamwell/flutter_gherkin
|
homepage: https://github.com/jonsamwell/flutter_gherkin
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in New Issue