Open golane-august opened 2 years ago
Also calling this with tagExpression: '@failure-expected'
:
flutter drive --driver=test_driver/integration_test_driver.dart --target=integration_test/gherkin_suite_test.dart -d chrome
results in:
FAILED: Scenario Failed expect() should be added to json report # ./integration_test/features/failure.feature:0
00:03 +2: (tearDownAll)
2 scenarios (2 failed)
4 steps (2 passed, 2 failed)
0:00:03.088000
00:03 +3: All tests passed!
Application finished.
Note the "All tests passed!", which sould not occur.
The problem seems to be that the generated executeTestSuite method is synchronous, but the run method is asynchronous:
void executeTestSuite({
required FlutterTestConfiguration configuration,
required StartAppFn appMainFunction,
Timeout scenarioExecutionTimeout = const Timeout(const Duration(minutes: 10)),
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
}) {
_CustomGherkinIntegrationTestRunner(
configuration: configuration,
appMainFunction: appMainFunction,
appLifecyclePumpHandler: appLifecyclePumpHandler,
scenarioExecutionTimeout: scenarioExecutionTimeout,
framePolicy: framePolicy,
).run();
}
Also the main method is done before the test setup is complete:
@GherkinTestSuite(
useAbsolutePaths: false,
)
void main() {
executeTestSuite(
appMainFunction: appInitializationFn,
configuration: gherkinTestConfiguration,
);
}
But Flutter assumes that with the end of the main method the test declaration is finished and does not allow any more calls on the test api (group, test, testWidgets, ...)
You could probably make the executeTestSuite method asynchronous and await it.
Future executeTestSuite({
required FlutterTestConfiguration configuration,
required StartAppFn appMainFunction,
Timeout scenarioExecutionTimeout = const Timeout(const Duration(minutes: 10)),
AppLifecyclePumpHandlerFn? appLifecyclePumpHandler,
LiveTestWidgetsFlutterBindingFramePolicy? framePolicy,
}) async {
return _CustomGherkinIntegrationTestRunner(
configuration: configuration,
appMainFunction: appMainFunction,
appLifecyclePumpHandler: appLifecyclePumpHandler,
scenarioExecutionTimeout: scenarioExecutionTimeout,
framePolicy: framePolicy,
).run();
}
@GherkinTestSuite(
useAbsolutePaths: false,
)
void main() async {
await executeTestSuite(
appMainFunction: appInitializationFn,
configuration: gherkinTestConfiguration,
);
}
What do you think @jonsamwell ?
@luvetter I edited you comment to translate the german sentence 😉
Can you use integration_test package instead of driver package to test the app?
Use:
Instead of:
But I get the error with
flutter test
:I used the example in integration_test__package_support: https://github.com/jonsamwell/flutter_gherkin/tree/integration_test__package_support/example_with_integration_test
I also tested
flutter run
with tagExpression@failure-expected
, but then the result doesn't match the failure: