flutter_gherkin_wrapper 1.0.5 flutter_gherkin_wrapper: ^1.0.5 copied to clipboard
Gherkin Wrapper is used to improve widget and integration tests with Cucumber / Gherkin notation
Flutter Gherkin Wrapper #
Wrapper on top of gherkin-package is used to execute widget and integration tests with Cucumber / Gherkin notation in a simplified mode. With autogenerated list of actions and nested scenarios.
Has to be used together with flutter_gherkin_generator
-package.
Getting started #
Check https://github.com/lyskouski/flutter_gherkin_wrapper/tree/main/example
Install:
dev_dependencies:
flutter_gherkin_generator: 1.0.4
flutter_gherkin_wrapper: 1.0.4
build_runner: ^2.4.6
Run:
dart run build_runner build --delete-conflicting-outputs
flutter test
Initialization #
// Generate steps from resources
// ./test/e2e/given/generic.dart
@GenerateGherkinResources(['../steps'])
class Generics extends GivenGeneric {
@override
RegExp get pattern => RegExp('%step%');
@override
// Execute sub-step
Future<void> executeStep() async {
final reporter = FileReporter();
final step = await FileReader().getFromString('''%feature%''', reporter);
final result = await FileRunner(FileRunner.tester, reporter).run(step);
if (!result) {
reporter.publish();
}
expectSync(result, true);
}
}
# /test/e2e/steps/open_expense_form.resource.feature
Feature: Verify Basic Actions
Scenario: Opened Expense Form
Given I am on "Home" page
When I tap "Add Bill, Income or Transfer" button
Then I can see "Add new Bill" button
Execution #
// Generate list of steps
@GenerateListOfClasses(['given', 'when', 'then'])
import 'steps_iterator.list.dart';
void main() {
Iterable<File> features = Directory('./test/e2e')
.listSync(recursive: true)
.where(
(entity) => entity is File && entity.path.endsWith('.test.feature'))
.cast<File>();
setUpAll(() {
TestWidgetsFlutterBinding.ensureInitialized();
ScreenCapture.enableScreenCapture();
ExecutableStepIterator.inject(classList);
// MainTest.cleanUpData();
});
group('Run All End-To-End Tests', () {
for (var file in features) {
testWidgets(file.path, (WidgetTester tester) async {
// await MainTest.init(tester);
final runner = FileRunner(tester);
await runner.init(file);
// ! to avoid collisions in concurrent requests
expectSync(await runner.run(), true);
await tester.pumpAndSettle();
}, timeout: const Timeout(Duration(minutes: 5)));
}
});
}
# /test/e2e/bill/create_different_expenses.test.feature
Feature: Verify Expenses Functionality
Scenario Outline: Added different Expenses
Given Opened Expense Form
When I select "<account>" from "AccountSelector" with "Enter Account Identifier" tooltip
And ...
In addition to thanking, you may treat us to ☕.