diff --git a/lib/src/scenario_generator.dart b/lib/src/scenario_generator.dart index 75f5fd2..1af4a53 100644 --- a/lib/src/scenario_generator.dart +++ b/lib/src/scenario_generator.dart @@ -120,15 +120,18 @@ Iterable _processScenarioLines( for (final line in lines.skip(1)) { yield BddLine.fromValue( line.type, - _replacePlaceholders(line.value, examples), + _replacePlaceholders( + line.value, line.type == LineType.dataTableStep, examples), ); } } -String _replacePlaceholders(String line, Map example) { +String _replacePlaceholders( + String line, bool isDataTableStep, Map example) { var replaced = line; for (final e in example.keys) { - replaced = replaced.replaceAll('<$e>', '{${example[e]}}'); + final value = isDataTableStep ? '${example[e]}' : '{${example[e]}}'; + replaced = replaced.replaceAll('<$e>', value); } return replaced; } diff --git a/test/data_tables_test.dart b/test/data_tables_test.dart index 5bc7926..da54746 100644 --- a/test/data_tables_test.dart +++ b/test/data_tables_test.dart @@ -485,4 +485,55 @@ Future theFollowingSongs(WidgetTester tester, String param1, bdd.DataTable expectedStep, ); }); + + test('Scenario Outline with data table variables', () { + const featureFile = ''' +Feature: Testing feature + Scenario Outline: Add and remove buttons work together + Given the app is running + When I tap add icon times + Then I see result + | 'counter' | 'color' | + | | | + Examples: + | times | counter | color | + | 20 | '20' | 'blue' | + | 25 | '25' | 'green' | +'''; + + const expectedFeatureDart = ''' +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +import 'package:bdd_widget_test/data_table.dart' as bdd; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import './step/the_app_is_running.dart'; +import './step/i_tap_add_icon_times.dart'; +import './step/i_see_result.dart'; + +void main() { + group(\'\'\'Testing feature\'\'\', () { + testWidgets(\'\'\'Outline: Add and remove buttons work together (20, '20', 'blue')\'\'\', (tester) async { + await theAppIsRunning(tester); + await iTapAddIconTimes(tester, 20); + await iSeeResult(tester, const bdd.DataTable([['counter', 'color'], ['20', 'blue']])); + }); + testWidgets(\'\'\'Outline: Add and remove buttons work together (25, '25', 'green')\'\'\', (tester) async { + await theAppIsRunning(tester); + await iTapAddIconTimes(tester, 25); + await iSeeResult(tester, const bdd.DataTable([['counter', 'color'], ['25', 'green']])); + }); + }); +} +'''; + + final feature = FeatureFile( + featureDir: 'test.feature', + package: 'test', + input: featureFile, + ); + expect(feature.dartContent, expectedFeatureDart); + }); }