Skip to content

Commit 26ce8a0

Browse files
committed
Cover more edge cases
1 parent 557f32f commit 26ce8a0

3 files changed

Lines changed: 271 additions & 14 deletions

File tree

β€Žtest/data_tables_test.dartβ€Ž

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,118 @@ void main() {
568568
});
569569
});
570570
}
571+
''';
572+
573+
final feature = FeatureFile(
574+
featureDir: 'test.feature',
575+
package: 'test',
576+
input: featureFile,
577+
);
578+
expect(feature.dartContent, expectedFeatureDart);
579+
});
580+
581+
test('Data table with single row (headers only)', () {
582+
const featureFile = '''
583+
Feature: Testing feature
584+
Scenario: Testing scenario
585+
Given the following songs
586+
| 'artist' | 'title' |
587+
''';
588+
589+
const expectedFeatureDart = '''
590+
// GENERATED CODE - DO NOT MODIFY BY HAND
591+
// ignore_for_file: type=lint, type=warning
592+
593+
import 'package:bdd_widget_test/data_table.dart' as bdd;
594+
import 'package:flutter/material.dart';
595+
import 'package:flutter_test/flutter_test.dart';
596+
597+
import './step/the_following_songs.dart';
598+
599+
void main() {
600+
group(\'\'\'Testing feature\'\'\', () {
601+
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
602+
await theFollowingSongs(tester, const bdd.DataTable([['artist', 'title']]));
603+
});
604+
});
605+
}
606+
''';
607+
608+
final feature = FeatureFile(
609+
featureDir: 'test.feature',
610+
package: 'test',
611+
input: featureFile,
612+
);
613+
expect(feature.dartContent, expectedFeatureDart);
614+
});
615+
616+
test('Data table with special characters in cells', () {
617+
const featureFile = '''
618+
Feature: Testing feature
619+
Scenario: Testing scenario
620+
Given the following data
621+
| 'name' | 'description' |
622+
| 'Test "One"' | 'Has quotes' |
623+
| 'Test <Two>' | 'Has angle brackets' |
624+
| 'Test {3}' | 'Has braces' |
625+
| 'Test, Four' | 'Has comma' |
626+
''';
627+
628+
const expectedFeatureDart = '''
629+
// GENERATED CODE - DO NOT MODIFY BY HAND
630+
// ignore_for_file: type=lint, type=warning
631+
632+
import 'package:bdd_widget_test/data_table.dart' as bdd;
633+
import 'package:flutter/material.dart';
634+
import 'package:flutter_test/flutter_test.dart';
635+
636+
import './step/the_following_data.dart';
637+
638+
void main() {
639+
group(\'\'\'Testing feature\'\'\', () {
640+
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
641+
await theFollowingData(tester, const bdd.DataTable([['name', 'description'], ['Test "One"', 'Has quotes'], ['Test <Two>', 'Has angle brackets'], ['Test {3}', 'Has braces'], ['Test, Four', 'Has comma']]));
642+
});
643+
});
644+
}
645+
''';
646+
647+
final feature = FeatureFile(
648+
featureDir: 'test.feature',
649+
package: 'test',
650+
input: featureFile,
651+
);
652+
expect(feature.dartContent, expectedFeatureDart);
653+
});
654+
655+
test('Data table with unicode and emoji', () {
656+
const featureFile = '''
657+
Feature: Testing feature
658+
Scenario: Testing scenario
659+
Given the following items
660+
| 'emoji' | 'description' |
661+
| 'πŸš€' | 'Rocket' |
662+
| 'πŸ’―' | 'Perfect' |
663+
| 'Γ‘oΓ±o' | 'Spanish' |
664+
''';
665+
666+
const expectedFeatureDart = '''
667+
// GENERATED CODE - DO NOT MODIFY BY HAND
668+
// ignore_for_file: type=lint, type=warning
669+
670+
import 'package:bdd_widget_test/data_table.dart' as bdd;
671+
import 'package:flutter/material.dart';
672+
import 'package:flutter_test/flutter_test.dart';
673+
674+
import './step/the_following_items.dart';
675+
676+
void main() {
677+
group(\'\'\'Testing feature\'\'\', () {
678+
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
679+
await theFollowingItems(tester, const bdd.DataTable([['emoji', 'description'], ['πŸš€', 'Rocket'], ['πŸ’―', 'Perfect'], ['Γ‘oΓ±o', 'Spanish']]));
680+
});
681+
});
682+
}
571683
''';
572684

573685
final feature = FeatureFile(

β€Žtest/feature_test.dartβ€Ž

Lines changed: 85 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:bdd_widget_test/src/feature_file.dart';
2-
import 'package:bdd_widget_test/src/generator_options.dart';
32
import 'package:test/test.dart';
43

54
import 'util/testing_data.dart';
@@ -108,18 +107,49 @@ void main() {
108107
);
109108
expect(feature.dartContent, expectedFeatureDart);
110109
});
111-
test('custom headers replace default imports in feature file', () async {
110+
111+
test('Feature with special characters in names', () {
112112
const expectedFeatureDart = '''
113-
${expectedComment}import 'package:patrol/patrol.dart';
114-
// Import flutter_test for compatibility
115-
import 'package:flutter_test/flutter_test.dart';
113+
$expectedComment// some comment
114+
115+
${expectedImports}import './step/the_app_is_running.dart';
116+
import './step/i_see_text.dart';
117+
118+
void main() {
119+
group(\'\'\'"Testing" <Special> {Characters}\'\'\', () {
120+
testWidgets(\'\'\'Test's "special" characters\'\'\', (tester) async {
121+
await theAppIsRunning(tester);
122+
await iSeeText(tester, 'test');
123+
});
124+
});
125+
}
126+
''';
116127

117-
import './step/the_app_is_running.dart';
128+
final feature = FeatureFile(
129+
featureDir: 'test.feature',
130+
package: 'test',
131+
input: '''
132+
// some comment
133+
134+
Feature: "Testing" <Special> {Characters}
135+
Scenario: Test's "special" characters
136+
Given the app is running
137+
Then I see {'test'} text
138+
''',
139+
);
140+
expect(feature.dartContent, expectedFeatureDart);
141+
});
142+
143+
test('Feature with very long step description', () {
144+
const expectedFeatureDart = '''
145+
${expectedHeader}import './step/the_app_is_running.dart';
146+
import './step/i_verify_that_this_is_a_very_long_step_description_that_tests_whether_the_framework_can_handle_extremely_long_step_names_without_issues.dart';
118147
119148
void main() {
120149
group(\'\'\'Testing feature\'\'\', () {
121150
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
122151
await theAppIsRunning(tester);
152+
await iVerifyThatThisIsAVeryLongStepDescriptionThatTestsWhetherTheFrameworkCanHandleExtremelyLongStepNamesWithoutIssues(tester);
123153
});
124154
});
125155
}
@@ -128,14 +158,55 @@ void main() {
128158
final feature = FeatureFile(
129159
featureDir: 'test.feature',
130160
package: 'test',
131-
input: minimalFeatureFile,
132-
generatorOptions: const GeneratorOptions(
133-
customHeaders: [
134-
"import 'package:patrol/patrol.dart';",
135-
'// Import flutter_test for compatibility',
136-
"import 'package:flutter_test/flutter_test.dart';",
137-
],
138-
),
161+
input: '''
162+
Feature: Testing feature
163+
Scenario: Testing scenario
164+
Given the app is running
165+
Then I verify that this is a very long step description that tests whether the framework can handle extremely long step names without issues
166+
''',
167+
);
168+
expect(feature.dartContent, expectedFeatureDart);
169+
});
170+
171+
test('Multiple scenarios in single feature', () {
172+
const expectedFeatureDart = '''
173+
${expectedHeader}import './step/the_app_is_running.dart';
174+
import './step/i_see_text.dart';
175+
import './step/i_tap_icon.dart';
176+
177+
void main() {
178+
group(\'\'\'Login feature\'\'\', () {
179+
testWidgets(\'\'\'Successful login\'\'\', (tester) async {
180+
await theAppIsRunning(tester);
181+
await iSeeText(tester, 'Login');
182+
});
183+
testWidgets(\'\'\'Failed login\'\'\', (tester) async {
184+
await theAppIsRunning(tester);
185+
await iSeeText(tester, 'Error');
186+
});
187+
testWidgets(\'\'\'Logout\'\'\', (tester) async {
188+
await iTapIcon(tester, Icons.logout);
189+
});
190+
});
191+
}
192+
''';
193+
194+
final feature = FeatureFile(
195+
featureDir: 'test.feature',
196+
package: 'test',
197+
input: '''
198+
Feature: Login feature
199+
Scenario: Successful login
200+
Given the app is running
201+
Then I see {'Login'} text
202+
203+
Scenario: Failed login
204+
Given the app is running
205+
Then I see {'Error'} text
206+
207+
Scenario: Logout
208+
When I tap {Icons.logout} icon
209+
''',
139210
);
140211
expect(feature.dartContent, expectedFeatureDart);
141212
});

β€Žtest/scenario_outline_test.dartβ€Ž

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,80 @@ void main() {
423423
});
424424
});
425425
}
426+
''';
427+
428+
final feature = FeatureFile(
429+
featureDir: 'test.feature',
430+
package: 'test',
431+
input: featureFile,
432+
);
433+
expect(feature.dartContent, expectedFeatureDart);
434+
});
435+
436+
test('Scenario Outline with Empty Examples Table', () {
437+
const featureFile = '''
438+
Feature: Testing feature
439+
Scenario Outline: Empty outline
440+
When I test <value> parameter
441+
442+
Examples:
443+
| value |
444+
''';
445+
446+
const expectedFeatureDart = '''
447+
// GENERATED CODE - DO NOT MODIFY BY HAND
448+
// ignore_for_file: type=lint, type=warning
449+
450+
import 'package:flutter/material.dart';
451+
import 'package:flutter_test/flutter_test.dart';
452+
453+
import './step/i_test_parameter.dart';
454+
455+
void main() {
456+
group(\'\'\'Testing feature\'\'\', () {
457+
});
458+
}
459+
''';
460+
461+
final feature = FeatureFile(
462+
featureDir: 'test.feature',
463+
package: 'test',
464+
input: featureFile,
465+
);
466+
expect(feature.dartContent, expectedFeatureDart);
467+
});
468+
469+
test('Scenario Outline with Unicode Characters in Variables', () {
470+
const featureFile = '''
471+
Feature: Testing feature
472+
Scenario Outline: Unicode variables
473+
When I see <emoji> icon
474+
475+
Examples:
476+
| emoji |
477+
| 'πŸš€' |
478+
| 'πŸ’―' |
479+
''';
480+
481+
const expectedFeatureDart = '''
482+
// GENERATED CODE - DO NOT MODIFY BY HAND
483+
// ignore_for_file: type=lint, type=warning
484+
485+
import 'package:flutter/material.dart';
486+
import 'package:flutter_test/flutter_test.dart';
487+
488+
import './step/i_see_icon.dart';
489+
490+
void main() {
491+
group(\'\'\'Testing feature\'\'\', () {
492+
testWidgets(\'\'\'Outline: Unicode variables ('πŸš€')\'\'\', (tester) async {
493+
await iSeeIcon(tester, 'πŸš€');
494+
});
495+
testWidgets(\'\'\'Outline: Unicode variables ('πŸ’―')\'\'\', (tester) async {
496+
await iSeeIcon(tester, 'πŸ’―');
497+
});
498+
});
499+
}
426500
''';
427501

428502
final feature = FeatureFile(

0 commit comments

Comments
Β (0)