|
1 | 1 | import 'package:bdd_widget_test/src/feature_file.dart'; |
| 2 | +import 'package:bdd_widget_test/src/step_file.dart'; |
2 | 3 | import 'package:flutter_test/flutter_test.dart'; |
3 | 4 |
|
4 | 5 | void main() { |
@@ -435,4 +436,53 @@ void main() { |
435 | 436 |
|
436 | 437 | expect(feature.dartContent, expectedFeatureDart); |
437 | 438 | }); |
| 439 | + test('Data table with parameters', () { |
| 440 | + const featureFile = ''' |
| 441 | +Feature: Testing feature |
| 442 | + Scenario: Testing scenario |
| 443 | + Given the following {'Good'} songs |
| 444 | + | artist | title | |
| 445 | + | 'The Beatles' | 'Let It Be' | |
| 446 | + | 'Camel' | 'Slow yourself down' | |
| 447 | +'''; |
| 448 | + |
| 449 | + const expectedFeatureDart = ''' |
| 450 | +// GENERATED CODE - DO NOT MODIFY BY HAND |
| 451 | +// ignore_for_file: unused_import, directives_ordering |
| 452 | +
|
| 453 | +import 'package:bdd_widget_test/data_table.dart' as bdd; |
| 454 | +import 'package:flutter/material.dart'; |
| 455 | +import 'package:flutter_test/flutter_test.dart'; |
| 456 | +
|
| 457 | +import './step/the_following_songs.dart'; |
| 458 | +
|
| 459 | +void main() { |
| 460 | + group(\'\'\'Testing feature\'\'\', () { |
| 461 | + testWidgets(\'\'\'Testing scenario\'\'\', (tester) async { |
| 462 | + await theFollowingSongs(tester, 'Good', const bdd.DataTable([[artist, title], ['The Beatles', 'Let It Be'], ['Camel', 'Slow yourself down']])); |
| 463 | + }); |
| 464 | + }); |
| 465 | +} |
| 466 | +'''; |
| 467 | + const expectedStep = ''' |
| 468 | +import 'package:bdd_widget_test/data_table.dart' as bdd; |
| 469 | +import 'package:flutter_test/flutter_test.dart'; |
| 470 | +
|
| 471 | +/// Usage: the following {'Good'} songs |
| 472 | +Future<void> theFollowingSongs(WidgetTester tester, String param1, bdd.DataTable dataTable) async { |
| 473 | + throw UnimplementedError(); |
| 474 | +} |
| 475 | +'''; |
| 476 | + |
| 477 | + final feature = FeatureFile( |
| 478 | + featureDir: 'test.feature', |
| 479 | + package: 'test', |
| 480 | + input: featureFile, |
| 481 | + ); |
| 482 | + expect(feature.dartContent, expectedFeatureDart); |
| 483 | + expect( |
| 484 | + (feature.getStepFiles().first as NewStepFile).dartContent, |
| 485 | + expectedStep, |
| 486 | + ); |
| 487 | + }); |
438 | 488 | } |
0 commit comments