Skip to content

Commit 7f3a38d

Browse files
committed
Fix data table parser
1 parent 9228996 commit 7f3a38d

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

lib/src/data_table_parser.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ Iterable<BddLine> replaceDataTables(List<BddLine> lines) sync* {
2121
lines[index].type == LineType.dataTableStep;
2222
final isNextLineTable = isTable(lines: lines, index: index + 1);
2323
if (isStep && isNextLineTable) {
24-
if (!hasExamplesFormat(bddLine: lines[index])) {
25-
yield* _createCucumberDataTable(lines: lines, index: index);
26-
} else {
27-
yield* _createDataTableFromExamples(lines: lines, index: index);
24+
final table = !hasExamplesFormat(bddLine: lines[index])
25+
? _createCucumberDataTable(lines: lines, index: index)
26+
: _createDataTableFromExamples(lines: lines, index: index);
27+
yield* table;
28+
// skip the parsed table
29+
while (isTable(lines: lines, index: index + 1)) {
30+
index++;
2831
}
2932
} else {
3033
yield lines[index];

test/data_tables_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,12 @@ void main() {
323323
Feature: Testing feature
324324
325325
Background:
326-
Given the following songs
326+
Given I wait
327+
And the following songs
327328
| artist | title |
328329
| 'The Beatles' | 'Let It Be' |
329330
| 'Camel' | 'Slow yourself down' |
331+
And I wait
330332
331333
Scenario: Testing scenario
332334
Given I wait
@@ -344,14 +346,16 @@ import 'package:bdd_widget_test/data_table.dart' as bdd;
344346
import 'package:flutter/material.dart';
345347
import 'package:flutter_test/flutter_test.dart';
346348
347-
import './step/the_following_songs.dart';
348349
import './step/i_wait.dart';
350+
import './step/the_following_songs.dart';
349351
import './step/the_following_users_exist.dart';
350352
351353
void main() {
352354
group(\'\'\'Testing feature\'\'\', () {
353355
Future<void> bddSetUp(WidgetTester tester) async {
356+
await iWait(tester);
354357
await theFollowingSongs(tester, const bdd.DataTable([[artist, title], ['The Beatles', 'Let It Be'], ['Camel', 'Slow yourself down']]));
358+
await iWait(tester);
355359
}
356360
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
357361
await bddSetUp(tester);
@@ -382,6 +386,7 @@ Feature: Testing feature
382386
| name | twitter |
383387
| 'Oleksandr' | '@olexale' |
384388
| 'Flutter' | '@FlutterDev' |
389+
And I wait
385390
386391
Scenario: Testing scenario
387392
Given the following songs
@@ -409,6 +414,7 @@ void main() {
409414
await iWait(tester);
410415
await theFollowingUsersExist(tester, 'Oleksandr', '@olexale');
411416
await theFollowingUsersExist(tester, 'Flutter', '@FlutterDev');
417+
await iWait(tester);
412418
}
413419
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
414420
try {

0 commit comments

Comments
 (0)