fix(integration_test): ensure tearDownAll is always run

This commit is contained in:
Jon Samwell 2021-01-21 15:41:24 +11:00
parent 230a8e8d5f
commit ef04fa3386
6 changed files with 22 additions and 5 deletions

View File

@ -109,6 +109,9 @@ flutter drive --driver=test_driver/integration_test_driver.dart --target=integra
11. Custom world need to extend `FlutterWorld` note `FlutterDriverWorld`.
12. If you change any of the feature files you will need to re-generate the tests using the below command
```
# you might need to run the clean command first if you have just changed feature files
flutter pub run build_runner clean
flutter pub run build_runner build
```

View File

@ -22,4 +22,5 @@ Feature: Creating todos
| Buy blueberries |
| Buy apples |
| Buy carrots |
Given I wait 5 seconds for the animation to complete
Given I wait 5 seconds for the animation to complete
When I test the default step timeout is not applied to step with custom timeout

View File

@ -8,6 +8,7 @@ import 'package:gherkin/gherkin.dart';
import 'hooks/reset_app_hook.dart';
import 'steps/expect_todos_step.dart';
import 'steps/when_await_animation.dart';
import 'steps/when_step_has_timeout.dart';
import 'world/custom_world.dart';
FlutterTestConfiguration gherkinTestConfiguration =
@ -15,6 +16,7 @@ FlutterTestConfiguration gherkinTestConfiguration =
[
thenIExpectTheTodos,
whenAnAnimationIsAwaited,
whenStepHasTimeout,
],
)
// ..tagExpression = '@debug'
@ -35,7 +37,6 @@ FlutterTestConfiguration gherkinTestConfiguration =
writeReport: (_, __) => Future<void>.value(),
),
]
..defaultTimeout = const Duration(minutes: 1)
..createWorld = (config) => Future.value(CustomWorld());
void Function(World) appInitializationFn = (World world) {

View File

@ -0,0 +1,12 @@
import 'package:gherkin/gherkin.dart';
import 'package:flutter_gherkin/flutter_gherkin_integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
final whenStepHasTimeout = when<FlutterWidgetTesterWorld>(
'I test the default step timeout is not applied to step with custom timeout',
(_) async {
await Future<void>.delayed(const Duration(seconds: 30));
},
configuration: StepDefinitionConfiguration()
..timeout = const Duration(seconds: 15),
);

View File

@ -54,13 +54,13 @@ abstract class GherkinIntegrationTestRunner {
_safeInvokeFuture(() async => await reporter.onTestRunStarted());
onRun();
tearDownAll(
() {
onRunComplete();
},
);
onRun();
}
void onRun();